BUG : Apache Hop unable to convert strings to date (for DST change 9 Mar 2025 2am to 3am) #5033
Replies: 4 comments 5 replies
-
DST: Timezone Update Tool |
Beta Was this translation helpful? Give feedback.
-
DST jumps from 2am to 3am, so the hour between 2 and 3 doesn't exist, so you'll need to add 1 hour to those values or convert them to UTC or something similar. |
Beta Was this translation helpful? Give feedback.
-
Java is quite picky about dates and times, you can't create a date that does not exist. One way to solve this is to add a second hop from your json input and use the "error handling" hop type. |
Beta Was this translation helpful? Give feedback.
-
DST define file(in JDK): $JAVA_HOME/lib/tzdb.dat 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);
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Apache Hop Team,
Context:
I have a JSON dataset with datetime fields that have values falling between 9th March 2.00 am to 3.00am. Daylight Savings Time (EDT) was implemented during this time. I am using JSON Input shape to parse the fields and while doing so also setting the datatype to 'Date'.
The JSON Input shapes fails for the all values falling between
2025-03-09T02:00:00.000+0000 to 2025-03-09T02:59:59.999+0000
Using the Format(yyyy-MM-dd'T'HH:mm:ss.SSS) to parse string json fields
The JSON Input shapes succeeds for below values:
Ask:
Thanks,
Apache Hop Newbie
Beta Was this translation helpful? Give feedback.
All reactions