mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-06 05:38:00 +08:00
Issue2447
This commit is contained in:
parent
a38e3e52af
commit
9a69b37007
@ -94,6 +94,8 @@ public class TemporalAccessorConverter extends AbstractConverter<TemporalAccesso
|
||||
protected TemporalAccessor convertInternal(Object value) {
|
||||
if (value instanceof Long) {
|
||||
return parseFromLong((Long) value);
|
||||
} else if (value instanceof Integer) {
|
||||
return parseFromLong((long) (Integer) value);
|
||||
} else if (value instanceof TemporalAccessor) {
|
||||
return parseFromTemporalAccessor((TemporalAccessor) value);
|
||||
} else if (value instanceof Date) {
|
||||
|
36
hutool-json/src/test/java/cn/hutool/json/Issue2447Test.java
Normal file
36
hutool-json/src/test/java/cn/hutool/json/Issue2447Test.java
Normal file
@ -0,0 +1,36 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Issue2447Test {
|
||||
|
||||
@Test
|
||||
public void addInteger() {
|
||||
Time time = new Time();
|
||||
time.setTime(LocalDateTime.of(1970, 1, 2, 10, 0, 1, 0));
|
||||
String timeStr = JSONUtil.toJsonStr(time);
|
||||
Assert.assertEquals(timeStr, "{\"time\":93601000}");
|
||||
Assert.assertEquals(JSONUtil.toBean(timeStr, Time.class).getTime(), time.getTime());
|
||||
}
|
||||
|
||||
static class Time {
|
||||
private LocalDateTime time;
|
||||
|
||||
public LocalDateTime getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(LocalDateTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return time.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user