Add new date format (#7189)

This commit is contained in:
ByteHamster 2024-05-20 20:25:12 +02:00 committed by GitHub
parent 84b6f442fc
commit fc1c13f4a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public abstract class DateUtils {
"EEE MMM d HH:mm yyyy",
"yyyy-MM-dd'T'HH:mm:ss",
"yyyy-MM-dd'T'HH:mm:ss.SSS Z",
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"yyyy-MM-dd'T'HH:mm:ss.SSS",
"yyyy-MM-dd'T'HH:mm:ssZ",
"yyyy-MM-dd'T'HH:mm:ss'Z'",

View File

@ -33,6 +33,15 @@ public class DateUtilsTest {
assertEquals(expected, actual);
}
@Test
public void testParseDateWithZuluTimezone() {
GregorianCalendar exp = new GregorianCalendar(2024, 4, 8, 22, 18, 52);
exp.setTimeZone(TimeZone.getTimeZone("UTC"));
Date expected = new Date(exp.getTimeInMillis() + 485);
Date actual = DateUtils.parse("2024-05-08T22:18:52.485Z");
assertEquals(expected, actual);
}
@Test
public void testParseDateWithDeciseconds() {
GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4);