优化时间转换

This commit is contained in:
zhou-hao 2020-09-29 09:51:27 +08:00
parent e322c28fa9
commit 15dd5dc9ca
2 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,10 @@ public class SmartDateDeserializer extends JsonDeserializer<Date> {
}
return TimeUtils.parseDate(str);
}
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
long ts = p.getLongValue();
return new Date(ts);
}
return null;
}
}

View File

@ -22,6 +22,7 @@ package org.jetlinks.community.utils;
import lombok.SneakyThrows;
import org.hswebframework.utils.time.DateFormatter;
import org.jetlinks.core.metadata.types.DateTimeType;
import org.springframework.util.StringUtils;
import java.time.*;
@ -166,6 +167,6 @@ public class DateMathParser {
if (StringUtils.isEmpty(value)) {
throw new IllegalArgumentException("cannot parse empty date");
}
return DateFormatter.fromString(value).getTime();
return DateTimeType.GLOBAL.convert(value).getTime();
}
}