Skip to content

Commit ea29f3a

Browse files
committed
Update epoch time handling in format modifier.
1 parent a0e6e19 commit ea29f3a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

httprpc-server/src/main/java/org/httprpc/io/TemplateEncoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ public Object apply(Object value, String argument, Locale locale, TimeZone timeZ
188188
}
189189

190190
static String format(Object value, DateTimeType dateTimeType, FormatStyle formatStyle, Locale locale, TimeZone timeZone) {
191-
if (value instanceof Long) {
192-
value = new Date((long)value);
191+
if (value instanceof Number) {
192+
value = new Date(((Number)value).longValue());
193193
}
194194

195195
if (value instanceof Date) {

template-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ For example, this marker transforms a date value into a medium-length, localized
8282

8383
Date/time values may be represented by one of the following:
8484

85-
* a `long` value representing epoch time in milliseconds
85+
* a numeric value representing epoch time in milliseconds
8686
* an instance of `java.util.Date`
8787
* an instance of `java.util.time.TemporalAccessor`
8888

0 commit comments

Comments
 (0)