1

I cannot find anywhere in the documentation how to parse the annual date string, e.g. 09-01 to AnnualDate. I'm saving AnnualDate as a string in the database and I need to convert it to AnnualDate when implementing custom conversion in EF.

The only constructor AnnualDate has is AnnualDate(int, int) and I cannot find the parse method anywhere.

1 Answer 1

4

It's the same as with all other NodaTime types - you use a pattern, in this case NodaTime.Text.AnnualDatePattern.

So:

var result = AnnualDatePattern.Iso.Parse(text);
if (result.Success)
{
    var annualDate = result.Value;
    ...
}
else
{
    // Handle failure
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.