Skip to content

feat: Move from JodaTime to java.time #16

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

juherr
Copy link

@juherr juherr commented Apr 2, 2025

Close #12

@juherr juherr force-pushed the feature/java-time branch 2 times, most recently from dfd7513 to 5822b29 Compare April 6, 2025 15:51
@juherr
Copy link
Author

juherr commented Apr 6, 2025

@goekay Updated with the new test cases.

@juherr juherr force-pushed the feature/java-time branch 5 times, most recently from b18f2bb to fc91344 Compare April 6, 2025 17:39
@juherr juherr force-pushed the feature/java-time branch from fc91344 to bf0233d Compare April 6, 2025 17:40
@juherr
Copy link
Author

juherr commented Apr 6, 2025

@goekay According to the specification:

image

Wouldn’t you agree that all date-time values should be in UTC?
Have you ever observed stations failing when non-UTC timestamps are used?

@juherr
Copy link
Author

juherr commented Apr 6, 2025

You can have a look at the potential change: juherr@b0f54a5

@goekay
Copy link
Member

goekay commented Apr 6, 2025

Wouldn’t you agree that all date-time values should be in UTC?

i would, but this is not the reality. you can find some steve issues with timestamp examples where timezone is missing. moreover, UTC is a strong recommendation but not a must for ocpp. in any case, this UTC enforcement should not come from this library. it is not the job of it. at best, we should remove the timezone parameter in steve and set it internally to UTC which would make this lib also work in UTC.

@juherr
Copy link
Author

juherr commented Apr 7, 2025

The purpose of the library is to read timestamps provided by the station and write timestamps that the station can handle.

From experience, we know that some stations omit the time zone in the timestamps they send. The library must therefore handle such cases gracefully.

On the other hand, since 2022-06-29T23:20:52.000Z and 2022-06-30T01:20:52+02:00 represent the same instant, the library is free to use the one recommended by the specification.
I didn’t find anything in the issues suggesting that a specific station would fail if UTC-formatted timestamps were used.

@goekay
Copy link
Member

goekay commented Apr 20, 2025

On the other hand, since 2022-06-29T23:20:52.000Z and 2022-06-30T01:20:52+02:00 represent the same instant, the library is free to use the one recommended by the specification.
I didn’t find anything in the issues suggesting that a specific station would fail if UTC-formatted timestamps were used.

agreed. no objections here. semantically, they represent the same point in time.

private final boolean marchallToUtc;

public JavaDateTimeConverter() {
this(ZoneId.systemDefault(), System.getProperty("steve.ocpp.marshall-to-utc", "true").equals("true"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont get why this property is necessary.

steve has a UTC setting, which has this consequence. finally, the library actually should just respect the zone id the java app runs in and that is it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property configures the zone used by the output format: utc as expected by the specification or the default java zone.

It helps when default zone is not UTC but you want to respect the specification.

As Steve configures utc by default both configuration will have the same effect.

UTC could always be used (my 1st implementation) but your test suite checks cases with not utc as default zone.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would find it a little bit weird that a subsystem (this lib) behaves differently than the main java system (steve). from my point of view, there should be only one timezone configuration that applies globally to the java app/process.

for example, if someone changes the default UTC timezone to something with UTC+2 hours such that we start adding the offset of 2h, then the date/times should reflect that new reality. we should not translate this back to UTC on OCPP messaging level.

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

Successfully merging this pull request may close these issues.

Get rid of Joda time dependency
2 participants