Merge in patch from #655
This commit is contained in:
parent
872d72629c
commit
e1cfc8212e
|
@ -43,13 +43,13 @@ public class BaseDateTimeDtDstu2Test {
|
||||||
Date from = Date.from(ldt.toInstant(ZoneOffset.UTC));
|
Date from = Date.from(ldt.toInstant(ZoneOffset.UTC));
|
||||||
InstantDt type = (InstantDt) new InstantDt(from).setTimeZoneZulu(true);
|
InstantDt type = (InstantDt) new InstantDt(from).setTimeZoneZulu(true);
|
||||||
String encoded = type.getValueAsString();
|
String encoded = type.getValueAsString();
|
||||||
|
|
||||||
ourLog.info("LDT: "+ ldt.toString());
|
ourLog.info("LDT: " + ldt.toString());
|
||||||
ourLog.info("Expected: "+"1960-09-07T00:44:25.012");
|
ourLog.info("Expected: " + "1960-09-07T00:44:25.012");
|
||||||
ourLog.info("Actual: "+encoded);
|
ourLog.info("Actual: " + encoded);
|
||||||
|
|
||||||
assertEquals("1960-09-07T00:44:25.012Z", encoded);
|
assertEquals("1960-09-07T00:44:25.012Z", encoded);
|
||||||
|
|
||||||
type = new InstantDt(encoded);
|
type = new InstantDt(encoded);
|
||||||
assertEquals(1960, type.getYear().intValue());
|
assertEquals(1960, type.getYear().intValue());
|
||||||
assertEquals(8, type.getMonth().intValue()); // 0-indexed unlike LocalDateTime.of
|
assertEquals(8, type.getMonth().intValue()); // 0-indexed unlike LocalDateTime.of
|
||||||
|
@ -65,11 +65,11 @@ public class BaseDateTimeDtDstu2Test {
|
||||||
public void testFromTime() {
|
public void testFromTime() {
|
||||||
long millis;
|
long millis;
|
||||||
InstantDt dt;
|
InstantDt dt;
|
||||||
|
|
||||||
millis = 1466022208001L;
|
millis = 1466022208001L;
|
||||||
String expected = "2016-06-15T20:23:28.001Z";
|
String expected = "2016-06-15T20:23:28.001Z";
|
||||||
validate(millis, expected);
|
validate(millis, expected);
|
||||||
|
|
||||||
millis = 1466022208123L;
|
millis = 1466022208123L;
|
||||||
expected = "2016-06-15T20:23:28.123Z";
|
expected = "2016-06-15T20:23:28.123Z";
|
||||||
validate(millis, expected);
|
validate(millis, expected);
|
||||||
|
@ -77,13 +77,12 @@ public class BaseDateTimeDtDstu2Test {
|
||||||
millis = 1466022208100L;
|
millis = 1466022208100L;
|
||||||
expected = "2016-06-15T20:23:28.100Z";
|
expected = "2016-06-15T20:23:28.100Z";
|
||||||
validate(millis, expected);
|
validate(millis, expected);
|
||||||
|
|
||||||
millis = 1466022208000L;
|
millis = 1466022208000L;
|
||||||
expected = "2016-06-15T20:23:28.000Z";
|
expected = "2016-06-15T20:23:28.000Z";
|
||||||
validate(millis, expected);
|
validate(millis, expected);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void validate(long millis, String expected) {
|
private void validate(long millis, String expected) {
|
||||||
InstantDt dt;
|
InstantDt dt;
|
||||||
|
@ -93,13 +92,12 @@ public class BaseDateTimeDtDstu2Test {
|
||||||
|
|
||||||
assertEquals(millis % 1000, dt.getMillis().longValue());
|
assertEquals(millis % 1000, dt.getMillis().longValue());
|
||||||
assertEquals((millis % 1000) * BaseDateTimeDt.NANOS_PER_MILLIS, dt.getNanos().longValue());
|
assertEquals((millis % 1000) * BaseDateTimeDt.NANOS_PER_MILLIS, dt.getNanos().longValue());
|
||||||
|
|
||||||
dt = new InstantDt();
|
dt = new InstantDt();
|
||||||
dt.setTimeZone(TimeZone.getTimeZone("GMT+0:00"));
|
dt.setTimeZone(TimeZone.getTimeZone("GMT+0:00"));
|
||||||
dt.setValue(new Date(millis));
|
dt.setValue(new Date(millis));
|
||||||
assertEquals(expected.replace("Z", "+00:00"), dt.getValueAsString());
|
assertEquals(expected.replace("Z", "+00:00"), dt.getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetPartialsYearFromExisting() {
|
public void testSetPartialsYearFromExisting() {
|
||||||
|
@ -262,7 +260,6 @@ public class BaseDateTimeDtDstu2Test {
|
||||||
verifyFails("1974-A2-25");
|
verifyFails("1974-A2-25");
|
||||||
verifyFails("1974-12-A5");
|
verifyFails("1974-12-A5");
|
||||||
|
|
||||||
|
|
||||||
// Date shouldn't have a time zone
|
// Date shouldn't have a time zone
|
||||||
verifyFails("1974-12-25Z");
|
verifyFails("1974-12-25Z");
|
||||||
verifyFails("1974-12-25+10:00");
|
verifyFails("1974-12-25+10:00");
|
||||||
|
|
Loading…
Reference in New Issue