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