mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix comment
This commit is contained in:
parent
63b93948a6
commit
0915b8918d
@ -18,7 +18,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Year;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Calendar;
|
||||
@ -542,8 +541,8 @@ public class DateUtil extends CalendarUtil {
|
||||
if (null == format || null == date) {
|
||||
return null;
|
||||
}
|
||||
/// java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: YearOfEra
|
||||
/// return format.format(date.toInstant());
|
||||
// java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: YearOfEra
|
||||
// 出现以上报错时,表示Instant时间戳没有时区信息,赋予默认时区
|
||||
return TemporalAccessorUtil.format(date.toInstant(), format);
|
||||
}
|
||||
|
||||
|
@ -1544,6 +1544,7 @@ public class ImgUtil {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static void write(Image image, File targetFile) throws IORuntimeException {
|
||||
FileUtil.touch(targetFile);
|
||||
ImageOutputStream out = null;
|
||||
try {
|
||||
out = getImageOutputStream(targetFile);
|
||||
|
@ -27,9 +27,12 @@ import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 基于Zxing的二维码工具类
|
||||
* 参见二维码网站:
|
||||
* <p>https://cli.im/text</p>
|
||||
* 基于Zxing的二维码工具类,支持:
|
||||
* <ul>
|
||||
* <li>二维码生成和识别,见{@link BarcodeFormat#QR_CODE}</li>
|
||||
* <li>条形码生成和识别,见{@link BarcodeFormat#CODE_39}等很多标准格式</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.2
|
||||
*/
|
||||
@ -79,7 +82,7 @@ public class QrCodeUtil {
|
||||
* 生成 Base64 编码格式的二维码,以 String 形式表示
|
||||
*
|
||||
* <p>
|
||||
* 输出格式为: data:image/[type];base64,[data]
|
||||
* 输出格式为: data:image/[type];base64,[data]
|
||||
* </p>
|
||||
*
|
||||
* @param content 内容
|
||||
|
@ -16,7 +16,6 @@ import java.io.File;
|
||||
* 二维码工具类单元测试
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public class QrCodeUtilTest {
|
||||
|
||||
@ -27,7 +26,7 @@ public class QrCodeUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// @Ignore
|
||||
public void generateCustomTest() {
|
||||
QrConfig config = new QrConfig();
|
||||
config.setMargin(0);
|
||||
@ -35,28 +34,25 @@ public class QrCodeUtilTest {
|
||||
// 背景色透明
|
||||
config.setBackColor(null);
|
||||
config.setErrorCorrection(ErrorCorrectionLevel.H);
|
||||
String path = FileUtil.isWindows() ? "d:/hutool/qrcodeCustom.png" : "~/Desktop/hutool/qrcodeCustom.png";
|
||||
if (!FileUtil.file(path).getParentFile().exists()) {
|
||||
FileUtil.file(path).getParentFile().mkdirs();
|
||||
}
|
||||
QrCodeUtil.generate("https://hutool.cn/", config, FileUtil.file(path));
|
||||
String path = FileUtil.isWindows() ? "d:/test/qrcodeCustom.png" : "~/Desktop/hutool/qrcodeCustom.png";
|
||||
QrCodeUtil.generate("https://hutool.cn/", config, FileUtil.touch(path));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void generateWithLogoTest() {
|
||||
String icon = FileUtil.isWindows() ? "d:/hutool/pic/face.jpg" : "~/Desktop/hutool/pic/face.jpg";
|
||||
String targetPath = FileUtil.isWindows() ? "d:/hutool/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
|
||||
String icon = FileUtil.isWindows() ? "d:/test/pic/face.jpg" : "~/Desktop/hutool/pic/face.jpg";
|
||||
String targetPath = FileUtil.isWindows() ? "d:/test/qrcodeWithLogo.jpg" : "~/Desktop/hutool/qrcodeWithLogo.jpg";
|
||||
QrCodeUtil.generate(//
|
||||
"http://hutool.cn/", //
|
||||
"https://hutool.cn/", //
|
||||
QrConfig.create().setImg(icon), //
|
||||
FileUtil.file(targetPath));
|
||||
FileUtil.touch(targetPath));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void decodeTest() {
|
||||
String decode = QrCodeUtil.decode(FileUtil.file("e:/pic/qr.png"));
|
||||
String decode = QrCodeUtil.decode(FileUtil.file("d:/test/pic/qr.png"));
|
||||
Console.log(decode);
|
||||
}
|
||||
|
||||
@ -68,18 +64,20 @@ public class QrCodeUtilTest {
|
||||
Console.log(decode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateAsBase64Test() {
|
||||
String base64 = QrCodeUtil.generateAsBase64("https://hutool.cn/", new QrConfig(400, 400), "png");
|
||||
Assert.assertNotNull(base64);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void generateAsBase64Test(){
|
||||
String base64 = QrCodeUtil.generateAsBase64("http://hutool.cn/", new QrConfig(400, 400), "png");
|
||||
System.out.println(base64);
|
||||
|
||||
public void generateAsBase64Test2() {
|
||||
byte[] bytes = FileUtil.readBytes(
|
||||
new File("d:/test/qr.png"));
|
||||
new File("d:/test/qr.png"));
|
||||
String encode = Base64.encode(bytes);
|
||||
String base641 = QrCodeUtil.generateAsBase64("http://hutool.cn/", new QrConfig(400, 400), "png", encode);
|
||||
System.out.println(base641);
|
||||
|
||||
String base641 = QrCodeUtil.generateAsBase64("https://hutool.cn/", new QrConfig(400, 400), "png", encode);
|
||||
Assert.assertNotNull(base641);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user