-
Notifications
You must be signed in to change notification settings - Fork 166
Serialize time to RFC3339 compliant string #249
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
Serialize time to RFC3339 compliant string #249
Conversation
e0c73cc to
dd9998f
Compare
|
In general looks good, but it breaks some test since it adds unnecessary zeros to fraction part of date ( public static final DateTimeFormatter RFC3339_DATE_FORMAT = new DateTimeFormatterBuilder()
.appendPattern("yyyy-MM-dd'T'HH:mm:ss")
.appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
.appendOffsetId()
.toFormatter();would work better than the above was used in previous version https://github.com/cloudevents/sdk-java/pull/216/files#diff-bac8dca098ba932b36f5b17870212371L34. Or maybe we could change assertions in the test, I think that would be acceptable too. /cc @slinkydeveloper |
Signed-off-by: Zhixuan Lai <zhixuan@squareup.com>
dd9998f to
de5db6b
Compare
|
@matejvasek fixed the test. It looks like |
|
I personally don't care about the more zeroes, if that's compliant to the spec, fine. I would love to avoid adding custom formats |
slinkydeveloper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matejvasek can you double check this one?
|
@zhxnlai my bad, I mistaken |
|
LGTM |
|
Note: when reading input we allow missing seconds, but for input it's OK to be less strict as is doesn't affect compatibility. |
|
@matejvasek @slinkydeveloper any chance we could roll this out soon? |
|
@zhxnlai I am not maintainer here (@slinkydeveloper is), but I would say probably not. This was merged just one day after releasing |
|
Technically this is a bug fix. My java application is stuck with milestone1 because it needs to interop with a go application that uses the go SDK. I am waiting for this fix to go out so that I can upgrade it to the latest Java SDK |
|
@zhxnlai Meanwhile you can use the snapshot packages, which should include this fix |
According to the documentation,
OffsetDateTime'stoStringmethod uses this formatuuuu-MM-dd'T'HH:mmXXXXXwhen seconds is zero. This is incompatible with RFC3339 and cannot be parsed by other cloud events SDKs.Here is an demo of the incompatibility:
https://play.golang.org/p/9db3zuJTM_k