-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4401,22 +4401,25 @@ public String toChar(long timestamp, String pattern) { | |
return sb.toString().trim(); | ||
} | ||
|
||
public String toCharPg(long timestamp, String pattern) { | ||
public static String toCharPg(DataContext root, long timestamp, String pattern) { | ||
final ZoneId zoneId = DataContext.Variable.TIME_ZONE.<TimeZone>get(root).toZoneId(); | ||
final Locale locale = DataContext.Variable.LOCALE.get(root); | ||
final Timestamp sqlTimestamp = internalToTimestamp(timestamp); | ||
final ZonedDateTime zonedDateTime = | ||
ZonedDateTime.of(sqlTimestamp.toLocalDateTime(), ZoneId.systemDefault()); | ||
return PostgresqlDateTimeFormatter.toChar(pattern, zonedDateTime).trim(); | ||
ZonedDateTime.of(sqlTimestamp.toLocalDateTime(), zoneId); | ||
return PostgresqlDateTimeFormatter.toChar(pattern, zonedDateTime, locale).trim(); | ||
Check failure on line 4410 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
|
||
} | ||
|
||
public int toDate(String dateString, String fmtString) { | ||
return toInt( | ||
new java.sql.Date(internalToDateTime(dateString, fmtString))); | ||
} | ||
|
||
public int toDatePg(String dateString, String fmtString) { | ||
public static int toDatePg(DataContext root, String dateString, String fmtString) { | ||
try { | ||
return (int) PostgresqlDateTimeFormatter.toTimestamp(dateString, fmtString, | ||
LOCAL_ZONE) | ||
final Locale locale = DataContext.Variable.LOCALE.get(root); | ||
return (int) PostgresqlDateTimeFormatter.toTimestamp(dateString, fmtString, LOCAL_ZONE, | ||
locale) | ||
Check failure on line 4422 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
|
||
.getLong(ChronoField.EPOCH_DAY); | ||
} catch (Exception e) { | ||
SQLException sqlEx = | ||
|
@@ -4433,9 +4436,11 @@ public long toTimestamp(String timestampString, String fmtString) { | |
new java.sql.Timestamp(internalToDateTime(timestampString, fmtString))); | ||
} | ||
|
||
public long toTimestampPg(String timestampString, String fmtString) { | ||
public static long toTimestampPg(DataContext root, String timestampString, String fmtString) { | ||
try { | ||
return PostgresqlDateTimeFormatter.toTimestamp(timestampString, fmtString, LOCAL_ZONE) | ||
final Locale locale = DataContext.Variable.LOCALE.get(root); | ||
return PostgresqlDateTimeFormatter.toTimestamp(timestampString, fmtString, LOCAL_ZONE, | ||
locale) | ||
Check failure on line 4443 in core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
|
||
.toInstant().toEpochMilli(); | ||
} catch (Exception e) { | ||
SQLException sqlEx = | ||
|