Azure / Azure/azure-sdk-for-java
[QUERY] Serialization of OffsetDateTime via BinaryData in clientcore
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 2.2k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 178
Description
**Query/Question**
Code on clientcore
```java
OffsetDateTime dateTime = OffsetDateTime.parse("2025-01-01T00:00:00Z");
// just a model with a OffsetDateTime property
DatetimeProperty model = new DatetimeProperty().setRequiredProperty("abc").setNullableProperty(dateTime);
String modelStr = BinaryData.fromObject(model).toString();
String scalarStr = BinaryData.fromObject(dateTime).toString();
```
The RFC3339 in `modelStr` is correct, `"property" : "2025-01-01T00:00:00Z"`.
The one in `scalarStr` is not correct, `"2025-01-01T00:00Z"`.
The same core on azure-core lib produces correct result, i.e. `"2025-01-01T00:00:00Z"`.
Link https://github.com/Azure/azure-sdk-for-java/issues/43792
***Why is this not a Bug or a feature Request?***
I am not sure whether serialize via BinaryData is the correct usage. But as generated code from emitter, we typically use this to serialize/de-serialize for request/response body.
**Setup (please complete the following information if applicable):**
- OS: [e.g. iOS]
- IDE: [e.g. IntelliJ]
- Library/Libraries: io.clientcore:core 1.0.0-beta.2
**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [x] Query Added
- [x] Setup information Added
Contributor guide
Assessment
This issue has not been assessed yet.