You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is that I have to use the timezone variable that's in the HeaderInfo in my custom serializer. How do I use timezone here from the HeaderInfo class? I essentially want to be be able to put the @JsonSerialize ( using = NanoTimestampSerializer.class ) annotation on any of the long time fields, and when serializing them, they automatically get serialized using the timezone field.
Now there's a couple of different ways I thought of solving this, I could add add the serializer as a module, and pass in the timezone information then, however that will apply the serialization to all long fields, while I only want it being applied to just the long time fields.
The other way is to introduce a wrapper to all the long timefields and then have a custom serializer for that. That way I can add the serializer as a module while not affecting all the other long fields, however this also seems inelegant.
publicclassTimeField {
privateLongvalue;
}
Would there be a better, more elegant solution to this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi so I have the following classes
Now inside the report classes, I have some long time fields, which I want to serialize differently, so I've made a custom serializer class
The issue is that I have to use the timezone variable that's in the HeaderInfo in my custom serializer. How do I use timezone here from the HeaderInfo class? I essentially want to be be able to put the
@JsonSerialize ( using = NanoTimestampSerializer.class )
annotation on any of the long time fields, and when serializing them, they automatically get serialized using the timezone field.Now there's a couple of different ways I thought of solving this, I could add add the serializer as a module, and pass in the timezone information then, however that will apply the serialization to all long fields, while I only want it being applied to just the long time fields.
The other way is to introduce a wrapper to all the long timefields and then have a custom serializer for that. That way I can add the serializer as a module while not affecting all the other long fields, however this also seems inelegant.
Would there be a better, more elegant solution to this?
Beta Was this translation helpful? Give feedback.
All reactions