Skip to content

Commit

Permalink
Update LSParseDateTime.java
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmitrah authored Dec 16, 2024
1 parent d155c83 commit 11be188
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,14 @@ private static lucee.runtime.type.dt.DateTime _call(PageContext pc, Object oDate
String strDate = StringUtil.replaceSpecialWhiteSpace(Caster.toString(oDate));

if (format != null && "epoch".equalsIgnoreCase(format.trim())) {
String seconds = oDate.toString();
long timeSeconds = Long.parseLong(seconds);
long milliseconds = timeSeconds*1000;
Instant instant = Instant.ofEpochMilli(milliseconds);
Instant instant = Instant.ofEpochMilli(Long.parseLong(oDate.toString()) * 1000);
LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
strDate = StringUtil.replaceSpecialWhiteSpace(Caster.toString(localDateTime));
return DateCaster.toDateTime(locale, strDate, tz, isUSLike(locale));
}

else if (format != null && "epochms".equalsIgnoreCase(format.trim())) {
String seconds = oDate.toString();
long timeSeconds = Long.parseLong(seconds);
long milliseconds = timeSeconds;
Instant instant = Instant.ofEpochMilli(milliseconds);
Instant instant = Instant.ofEpochMilli(Long.parseLong(oDate.toString()));
LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
strDate = StringUtil.replaceSpecialWhiteSpace(Caster.toString(localDateTime));
return DateCaster.toDateTime(locale, strDate, tz, isUSLike(locale));
Expand Down Expand Up @@ -139,4 +134,4 @@ public static final boolean isUSLike(Locale locale) {
if (locale == null) return false;
return locale.getLanguage().equalsIgnoreCase("en") && (StringUtil.isEmpty(locale.getCountry()) || "US".equalsIgnoreCase(locale.getCountry()));
}
}
}

0 comments on commit 11be188

Please sign in to comment.