domino-jna icon indicating copy to clipboard operation
domino-jna copied to clipboard

NotesTimeDate .setAnyDate and .setAnyTime doesn't handle timezones correctly

Open Gegga87 opened this issue 4 months ago • 0 comments

Hello,

I noticed today that if I use .setAnyDate on a NotesDateTime() this will revert the timezone back to UTC even if the time was correct before doing the call.

cal.setTimeInMillis(Long.parseLong("1728603007000"));

NotesTimeDate timePart = new NotesTimeDate(cal); 
System.out.println("1: "+ timePart.toString());

timePart.setAnyDate();
System.out.println("2: "+ timePart.toString());

timePart.setTimeZone(TimeZone.getTimeZone("Europe/Stockholm"));
System.out.println("3: "+ timePart.toString());

output:
1: 2024-10-11 01:30:07 CEDT
2: 23:30:07
3: ****-05-10 01:30:07 CEDT

When I try to set the timezone on a NotesTimeDate object after I have called .setAnyDate it will be formated as ****-05-10 01:30:07 CEDT this is the result with the timestamp 1728603007000 which is 2024-10-10 23:30:07 GMT in the Europe/Stockholm timezone.

.setAnyTime still fails when the date changes with the timestamp above it will result in 2024-10-10 instead of 2024-10-11 which would be correct in my timezone.

I found that NotesDateTimeUtils.toAnyTime/.toAnyDate when called before calling the NotesTimeDate constructor works correctly however. example below.

cal.setTimeInMillis(timestamp);
NotesDateTimeUtils.setAnyDate(cal);
NotesTimeDate timePart = new NotesTimeDate(cal); 

So it's not a huge issue for me at the moment but I was confused that the values reverted back to UTC and I suppose it might cause issues for others as well.

To me it seems weird that m_guessedTimezone is set to null in these methods but I also don't fully understand the implementation with the m_innards Array either.

https://github.com/klehmann/domino-jna/blob/76aa418da8c4f7e0b7f7779bf51b18dcd6e533bf/domino-jna/src/main/java/com/mindoo/domino/jna/NotesTimeDate.java#L598

Gegga87 avatar Oct 10 '24 10:10 Gegga87