Add and use TimeZones.GMT.
This commit is contained in:
parent
c267e39091
commit
eea85f25e5
|
@ -80,6 +80,7 @@ The <action> type attribute can be add,update,fix,remove.
|
||||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedExecutionException.</action>
|
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedExecutionException.</action>
|
||||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedTimeoutException.</action>
|
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedTimeoutException.</action>
|
||||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedInterruptedException.</action>
|
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedInterruptedException.</action>
|
||||||
|
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TimeZones.GMT.</action>
|
||||||
<!-- UPDATE -->
|
<!-- UPDATE -->
|
||||||
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
|
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
|
||||||
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>
|
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.commons.lang3.time;
|
package org.apache.commons.lang3.time;
|
||||||
|
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps to deal with {@link java.util.TimeZone}s.
|
* Helps to deal with {@link java.util.TimeZone}s.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +26,7 @@ package org.apache.commons.lang3.time;
|
||||||
*/
|
*/
|
||||||
public class TimeZones {
|
public class TimeZones {
|
||||||
|
|
||||||
// do not instantiate
|
// Do not instantiate.
|
||||||
private TimeZones() {
|
private TimeZones() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,4 +34,11 @@ public class TimeZones {
|
||||||
* A public version of {@link java.util.TimeZone}'s package private {@code GMT_ID} field.
|
* A public version of {@link java.util.TimeZone}'s package private {@code GMT_ID} field.
|
||||||
*/
|
*/
|
||||||
public static final String GMT_ID = "GMT";
|
public static final String GMT_ID = "GMT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The GMT time zone.
|
||||||
|
*
|
||||||
|
* @since 3.13.0
|
||||||
|
*/
|
||||||
|
public static final TimeZone GMT = TimeZone.getTimeZone(GMT_ID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class FastDateParserTest {
|
||||||
|
|
||||||
private static final TimeZone REYKJAVIK = TimeZone.getTimeZone("Atlantic/Reykjavik");
|
private static final TimeZone REYKJAVIK = TimeZone.getTimeZone("Atlantic/Reykjavik");
|
||||||
private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
|
private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
|
||||||
static final TimeZone GMT = TimeZone.getTimeZone(TimeZones.GMT_ID);
|
static final TimeZone GMT = TimeZones.GMT;
|
||||||
private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta");
|
private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta");
|
||||||
|
|
||||||
private static final Locale SWEDEN = new Locale("sv", "SE");
|
private static final Locale SWEDEN = new Locale("sv", "SE");
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class FastDatePrinterTest {
|
||||||
}
|
}
|
||||||
private static final String YYYY_MM_DD = "yyyy/MM/dd";
|
private static final String YYYY_MM_DD = "yyyy/MM/dd";
|
||||||
private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
|
private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York");
|
||||||
private static final TimeZone GMT = TimeZone.getTimeZone(TimeZones.GMT_ID);
|
private static final TimeZone GMT = TimeZones.GMT;
|
||||||
private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta");
|
private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta");
|
||||||
|
|
||||||
private static final Locale SWEDEN = new Locale("sv", "SE");
|
private static final Locale SWEDEN = new Locale("sv", "SE");
|
||||||
|
@ -126,7 +126,7 @@ public class FastDatePrinterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendableOptions() {
|
public void testAppendableOptions() {
|
||||||
final DatePrinter format = getInstance("yyyy-MM-dd HH:mm:ss.SSS Z", TimeZone.getTimeZone(TimeZones.GMT_ID));
|
final DatePrinter format = getInstance("yyyy-MM-dd HH:mm:ss.SSS Z", TimeZones.GMT);
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
final String expected = format.format(calendar, sb).toString();
|
final String expected = format.format(calendar, sb).toString();
|
||||||
|
@ -262,7 +262,7 @@ public class FastDatePrinterTest {
|
||||||
cal.clear();
|
cal.clear();
|
||||||
cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16);
|
cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16);
|
||||||
|
|
||||||
final DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone(TimeZones.GMT_ID));
|
final DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZones.GMT);
|
||||||
assertEquals("2009-10-16T16:42:16.000Z", format.format(cal.getTime()), "dateTime");
|
assertEquals("2009-10-16T16:42:16.000Z", format.format(cal.getTime()), "dateTime");
|
||||||
assertEquals("2009-10-16T16:42:16.000Z", format.format(cal), "dateTime");
|
assertEquals("2009-10-16T16:42:16.000Z", format.format(cal), "dateTime");
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ public class FastDatePrinterTest {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testStringBufferOptions() {
|
public void testStringBufferOptions() {
|
||||||
final DatePrinter format = getInstance("yyyy-MM-dd HH:mm:ss.SSS Z", TimeZone.getTimeZone(TimeZones.GMT_ID));
|
final DatePrinter format = getInstance("yyyy-MM-dd HH:mm:ss.SSS Z", TimeZones.GMT);
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuffer sb = new StringBuffer();
|
||||||
final String expected = format.format(calendar, sb, new FieldPosition(0)).toString();
|
final String expected = format.format(calendar, sb, new FieldPosition(0)).toString();
|
||||||
|
|
Loading…
Reference in New Issue