This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new b78e81f5a9 Update datetime testing due to Java timezone changes
b78e81f5a9 is described below
commit b78e81f5a9408433435afdc58d41436624594c9d
Author: Andy Seaborne <[email protected]>
AuthorDate: Sat Feb 28 18:00:14 2026 +0000
Update datetime testing due to Java timezone changes
---
.../apache/jena/atlas/lib/TestDateTimeUtils.java | 33 ++++++++++++++++++----
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git
a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestDateTimeUtils.java
b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestDateTimeUtils.java
index d9338a133b..9a26504b4e 100644
--- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestDateTimeUtils.java
+++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestDateTimeUtils.java
@@ -29,12 +29,34 @@ import java.util.TimeZone;
import org.junit.jupiter.api.Test;
public class TestDateTimeUtils {
+ // Why tzNameMinus7?
+ //
+ // These tests were written using "MST" (US Mountain Standard Time,
-07:00).
+ //
+ // Java25 prints a warning
+ // WARNING: Use of the three-letter time zone ID "MST" is deprecated and
it will be removed in a future release
+ //
+ // The problem is that "MST" is used loosely, e.g. "Denver timezone is MST"
+ // but Denver observes daylight savings time ("MDT") for part of the year.
+ //
+ //
+ // The same is true for CET (Central European Time) / CEST (S = Summer)
+ // Java is deprecating for removal most three letter timeone.
+ //
+ // The use of 1984, MARCH means these tests are not fragile (it was not in
US DST).
+ // In 1984, US DST was from Sun April 29 02:00 to Sun October 28 02:00.
+ // US DST started first Sunday in April.
+ // US moved the start of DST to the second Sunday in March in 2007
+ //
+ // "America/Phoenix" is -07:00 all year round.
+
+ private static final String tzNameMinus7 = "America/Phoenix";
@Test
public void testCalendarToXSDDateTimeString_1() {
Calendar cal = createCalendar(1984, Calendar.MARCH, 22, 14, 32,
1, 0, "Z") ;
assertEquals("1984-03-22T14:32:01+00:00",
DateTimeUtils.calendarToXSDDateTimeString(cal));
- cal.setTimeZone(TimeZone.getTimeZone("MST"));
+ cal.setTimeZone(TimeZone.getTimeZone(tzNameMinus7));
assertEquals("1984-03-22T07:32:01-07:00",
DateTimeUtils.calendarToXSDDateTimeString(cal));
}
@@ -42,17 +64,16 @@ public class TestDateTimeUtils {
public void testCalendarToXSDDateTimeString_2() {
Calendar cal = createCalendar(1984, Calendar.MARCH, 22, 14, 32, 1, 50,
"Z") ;
assertEquals("1984-03-22T14:32:01.050+00:00",
DateTimeUtils.calendarToXSDDateTimeString(cal));
- cal.setTimeZone(TimeZone.getTimeZone("MST"));
+ cal.setTimeZone(TimeZone.getTimeZone(tzNameMinus7));
assertEquals("1984-03-22T07:32:01.050-07:00",
DateTimeUtils.calendarToXSDDateTimeString(cal));
}
-
@Test
public void testCalendarToXSDDateString() {
Calendar cal = createCalendar(1984, Calendar.MARCH, 22, 23, 59,
1, 0, "Z");
cal.setTimeZone(TimeZone.getTimeZone("Z")) ;
assertEquals("1984-03-22+00:00",
DateTimeUtils.calendarToXSDDateString(cal));
- cal.setTimeZone(TimeZone.getTimeZone("MST"));
+ cal.setTimeZone(TimeZone.getTimeZone(tzNameMinus7));
assertEquals("1984-03-22-07:00",
DateTimeUtils.calendarToXSDDateString(cal));
}
@@ -61,7 +82,7 @@ public class TestDateTimeUtils {
Calendar cal = createCalendar(1984, Calendar.MARCH, 22, 14, 32,
1, 0, "GMT+01:00");
assertEquals("14:32:01+01:00",
DateTimeUtils.calendarToXSDTimeString(cal));
// Different timezone - moves the cal point-in-time.
- cal.setTimeZone(TimeZone.getTimeZone("MST"));
+ cal.setTimeZone(TimeZone.getTimeZone(tzNameMinus7));
assertEquals("06:32:01-07:00",
DateTimeUtils.calendarToXSDTimeString(cal));
}
@@ -70,7 +91,7 @@ public class TestDateTimeUtils {
Calendar cal = createCalendar(1984, Calendar.MARCH, 22, 14, 32, 1,
500, "GMT+01:00");
assertEquals("14:32:01.500+01:00",
DateTimeUtils.calendarToXSDTimeString(cal));
// Different timezone - moves the cal point-in-time.
- cal.setTimeZone(TimeZone.getTimeZone("MST"));
+ cal.setTimeZone(TimeZone.getTimeZone(tzNameMinus7));
assertEquals("06:32:01.500-07:00",
DateTimeUtils.calendarToXSDTimeString(cal));
}