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
AbpJsonOptions DefaultDateTimeFormat not applied #12604
Comments
This is a typical XY problem, please describe your original problem in detail. |
@maliming The original problem is that an entity has a DateTime property. I am using Entity Framework as the database provider. When the entity is retrieved from the database the DateTime kind is set to unspecified. Because of this the serializer is not adding the 'Z' in the end because it doesn't know it is a UTC kind. That's why I wanted to specify the format myself since all the datetimes are always UTC. I am also configuring the clock: Configure<AbpClockOptions>(options => options.Kind = DateTimeKind.Utc); |
Our framework has unit tests ensure that the problem you mentioned do not happen. Can you reproduce it with unit tests or a template project? |
After a lot of debugging I found the issue. It was because I am using a custom serializer that I forgot about. This serializer is set as an attribute on the Dto and it is only used in inheritance so the discriminator property is automatically serialized. However because this is a custom serializer the other serializers are not being applied anymore 🤦♂️ |
Created a a new ABP project with the cli. In the HttpApiHost Module I added this:
Added a simple application service:
When testing the endpoint the result was:
How can I get the datetime to serialize as the provided AbpJsonOptions.DefaultDateTimeFormat ?
The actual issue I am facing in my original project is that the 'Z' is missing in the end. So when a datetime is serialized it shows as 2022-05-12T22:22:08.8273489 instead of 2022-05-12T22:22:08.8273489Z
The text was updated successfully, but these errors were encountered: