package jnpf.base.util; import org.junit.Test; import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; public class DateTimeFormatConstantTest { @Test public void parsesOffsetDateTimeStoredByPostgres() { String value = "2026-09-22 16:32:48.399+08"; long expected = OffsetDateTime.parse(value.replace(' ', 'T'), DateTimeFormatter.ISO_OFFSET_DATE_TIME) .toInstant().toEpochMilli(); assertEquals(expected, DateTimeFormatConstant.getDateObjToLong(value).longValue()); } @Test public void keepsLocalDateFormatsSupported() { assertNotNull(DateTimeFormatConstant.getDateObjToLong("2026-09-22 16:32:48")); assertNotNull(DateTimeFormatConstant.getDateObjToLong("2026-09-22")); } }