I am getting a parsing exception while I am trying the following code
public class Timezone {
public static void main(String[] args) {
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone tz;
LocalDateTime now = LocalDateTime.now();
final DateTimeFormatter ICS_DATE_FORMATTER =
DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss");
//tz = registry.getTimeZone("Asia/Calcutta");
tz = registry.getTimeZone("Australia/Lord_Howe");
DtStart dtstart;
try {
dtstart = new DtStart(now.format(ICS_DATE_FORMATTER),tz);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java.text.ParseException: Unparseable date: "20221207T170935"
at java.base/java.text.DateFormat.parse(DateFormat.java:395)
at net.fortuna.ical4j.model.DateTime.setTime(DateTime.java:418)
at net.fortuna.ical4j.model.DateTime.<init>(DateTime.java:325)
at net.fortuna.ical4j.model.property.DateProperty.setValue(DateProperty.java:137)
at net.fortuna.ical4j.model.property.DtStart.<init>(DtStart.java:146)
at Timezone.main(Timezone.java:33)
I have used ical4j 3.0.19 jar and their dependency jar .
Its working for all the timezone except for the timezone "Australia/Lord_Howe".
I am expecting the Dtstart value as :
DTSTART;TZID=Australia/Lord_Howe:20221207T170935
No need for parsing:
Prints
So far I haven't got the source of the version I'm using (4.0.0-beta4). Yes, it's a beta, but I suspect they might have supported
Temporalfor some time. Actually I discover that all versions 4.x support it.My guess is that they'll fix the above ctor in time to act on
ZonedDateTimeas the initializing type, since, at the moment, if that's used,DtStart.toStringshows no sign of the zone.