GitHub user shlxue added a comment to the discussion: BUG : Apache Hop unable
to convert strings to date (for DST change 9 Mar 2025 2am to 3am)
DST define file(in JDK): $JAVA_HOME/lib/tzdb.dat
and the file is not static data, it will be updated continuously.
List some of DST by api of jdk:
```java
static int timesLimit = 220;
public static void main(String[] args) {
// showDst("Asia/Shanghai", 1097, 9, 15, 2, 0);
showDst("America/New_York", 1097, 9, 15, 2, 0);
}
private static void showDst(String zone, int year, int month, int dayOfMonth,
int hour, int minute) {
ZoneId zoneId = ZoneId.of(zone);
// Get the ZoneRules for the specified ZoneId
ZoneRules zoneRules = zoneId.getRules();
ZonedDateTime now = ZonedDateTime.of(LocalDateTime.of(year, month,
dayOfMonth, hour, minute), zoneId);
System.out.println("Current time in Asia/Shanghai: " + now);
// Check if DST is in effect for the current date
boolean isDST = zoneRules.isDaylightSavings(now.toInstant());
System.out.println("Is DST in effect? " + isDST);
// Display the transition rules
System.out.println("Daylight Saving Time offset: " +
zoneRules.getDaylightSavings(now.toInstant()));
// Display the next DST transition
System.out.println("Next DST transition: " +
zoneRules.nextTransition(now.toInstant()));
// Display the previous DST transition
System.out.println("Previous DST transition: " +
zoneRules.previousTransition(now.toInstant()));
ZoneOffsetTransition next = zoneRules.nextTransition(now.toInstant());
if (next != null && timesLimit > 0) {
timesLimit--;
LocalDateTime dateTime = next.getDateTimeAfter();
int nextYear = dateTime.getYear();
int nextMonth = dateTime.getMonthValue();
int nextDay = dateTime.getDayOfMonth();
if (nextDay > 28) {
nextDay =1;
nextMonth++;
} else {
nextDay++;
}
if (nextMonth > 12) {
nextMonth = 1;
nextYear++;
}
showDst(zone, nextYear, nextMonth, nextDay, hour, minute);
}
}
```
GitHub link:
https://github.com/apache/hop/discussions/5033#discussioncomment-12514386
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]