Skip to content
Advertisement

How to Validate Ordinal Dates?

My julian date is in 7 digit format YYYYDDD. I want to make sure all the scenarios of leap years should be covered. Currently I have put a check on days. Is there any utility validating it ?

Advertisement

Answer

I want to make sure all the scenarios of leap years should be covered. Currently I have put a check on days. Is there any utility validating it ?

Yes, simply format the strings to LocalDate using the pattern, uuuuDDD and the leap years will be automatically be taken into consideration by the parsing API.

Demo:

JavaScript

Output:

JavaScript
Advertisement