Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gegga87 opened this issue Oct 10, 2024 · 0 comments

Comments

@Gegga87
Copy link

Gegga87 commented Oct 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant