Add support for zzz timezone format
This commit is contained in:
parent
c1edc939a0
commit
465838d4b6
@ -23,6 +23,8 @@ public final class DateUtils {
|
||||
|
||||
private static final String ISO_PATTERN = ".SSSZZ";
|
||||
|
||||
private static final String EDT_PATTERN = "zzz";
|
||||
|
||||
/**
|
||||
* Date pattern for format : 2019-01-04T22:21:46+00:00
|
||||
*/
|
||||
@ -35,6 +37,7 @@ public final class DateUtils {
|
||||
.appendOptional(DateTimeFormat.forPattern(GMT_PATTERN).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(OFFSET_PATTERN).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(ISO_PATTERN).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(EDT_PATTERN).getParser())
|
||||
.toFormatter()
|
||||
.withLocale(Locale.ENGLISH)
|
||||
.withOffsetParsed();
|
||||
|
@ -7,11 +7,6 @@ import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class DateUtilsTest {
|
||||
|
||||
@Test
|
||||
@ -46,7 +41,13 @@ public class DateUtilsTest {
|
||||
public void isoPatternTest() {
|
||||
LocalDateTime dateTime = new LocalDateTime(2020, 6, 30, 11, 39, 37, 206);
|
||||
|
||||
|
||||
assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("2020-06-30T11:39:37.206-07:00")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void edtPatternTest() {
|
||||
LocalDateTime dateTime = new LocalDateTime(2020, 7, 17, 16, 30, 0);
|
||||
|
||||
assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("Fri, 17 Jul 2020 16:30:00 EDT")));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user