From a627235cacef2e839f675eb8b192b9dd81981ec3 Mon Sep 17 00:00:00 2001 From: lvca Date: Thu, 9 Nov 2023 14:45:20 -0500 Subject: [PATCH] Fixed typo --- .../query/sql/function/time/SQLFunctionDate.java | 2 +- .../src/main/java/com/arcadedb/utility/DateUtils.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/engine/src/main/java/com/arcadedb/query/sql/function/time/SQLFunctionDate.java b/engine/src/main/java/com/arcadedb/query/sql/function/time/SQLFunctionDate.java index 23212b7d84..55ea13b183 100644 --- a/engine/src/main/java/com/arcadedb/query/sql/function/time/SQLFunctionDate.java +++ b/engine/src/main/java/com/arcadedb/query/sql/function/time/SQLFunctionDate.java @@ -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; diff --git a/engine/src/main/java/com/arcadedb/utility/DateUtils.java b/engine/src/main/java/com/arcadedb/utility/DateUtils.java index 9959391168..25f37af6bd 100755 --- a/engine/src/main/java/com/arcadedb/utility/DateUtils.java +++ b/engine/src/main/java/com/arcadedb/utility/DateUtils.java @@ -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;