AvroConvert icon indicating copy to clipboard operation
AvroConvert copied to clipboard

Provide a way to serialize DateTime using millis or micros

Open robertcoltheart opened this issue 1 year ago • 2 comments

Describe the solution you'd like We have a need to serialize DateTime values as a millis logical type, not micros, which is the default. There isn't a way to select a different logical type that I can see.

Describe implementation idea Perhaps a LogicalTypeAttribute with a way to select a specific logical type for a property would be the way to go? I'm not sure what other mechanism could solve this, though you may perhaps have some ideas.

robertcoltheart avatar Apr 04 '24 04:04 robertcoltheart

Hey, Maybe it would make sense to create a fully flexible AvroTypeAttribute. I will check out the options. Best, Adrian

AdrianStrugala avatar Apr 05 '24 05:04 AdrianStrugala

Hello @robertcoltheart

Thank you for your contribution. The new feature is available from v.3.4.7 of AvroConvert. Example usage:

    public class TypeAttributeClass
    {
        [AvroType(AvroTypeRepresentation.Double)]
        public int Int;

        [AvroType(AvroTypeRepresentation.TimestampMilliseconds)]
        public DateTime DateTime;
    }

Regards, Adrian

AdrianStrugala avatar Apr 26 '24 14:04 AdrianStrugala