Skip to content

Commit

Permalink
Fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Nov 9, 2023
1 parent 2c5baa5 commit a627235
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Object execute(final Object iThis, final Identifiable iCurrentRecord, fin
if (iParams.length == 0 || iParams[0] == null)
date = LocalDateTime.now();
else if (iParams[0] instanceof Number)
date = DateUtils.millisTolocalDateTime(((Number) iParams[0]).longValue());
date = DateUtils.millisToLocalDateTime(((Number) iParams[0]).longValue());
else if (iParams[0] instanceof String) {
final String dateAsString = (String) iParams[0];
final String format;
Expand Down
10 changes: 7 additions & 3 deletions engine/src/main/java/com/arcadedb/utility/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,19 @@ else if (obj instanceof LocalDateTime || obj instanceof ZonedDateTime || obj ins
return highestPrecision;
}

public static LocalDateTime millisTolocalDateTime(final long millis) {
public static LocalDateTime millisToLocalDateTime(final long millis) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.systemDefault()).toLocalDateTime();
}

public static LocalDate millisToLocalDate(final long millis) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.systemDefault()).toLocalDate();
}

public static String format(final Object obj, final String format) {
if (obj instanceof Date)
return getFormatter(format).format(millisTolocalDateTime(((Date) obj).getTime()));
return getFormatter(format).format(millisToLocalDateTime(((Date) obj).getTime()));
else if (obj instanceof Calendar)
return getFormatter(format).format(millisTolocalDateTime(((Calendar) obj).getTimeInMillis()));
return getFormatter(format).format(millisToLocalDateTime(((Calendar) obj).getTimeInMillis()));
else if (obj instanceof TemporalAccessor)
return getFormatter(format).format((TemporalAccessor) obj);
return null;
Expand Down

0 comments on commit a627235

Please sign in to comment.