use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.
the class TCKZoneOffset method test_factory_string_hours_minutes_colon.
@Test
public void test_factory_string_hours_minutes_colon() {
for (int i = -17; i <= 17; i++) {
for (int j = -59; j <= 59; j++) {
if ((i < 0 && j <= 0) || (i > 0 && j >= 0) || i == 0) {
String str = (i < 0 || j < 0 ? "-" : "+") + Integer.toString(Math.abs(i) + 100).substring(1) + ":" + Integer.toString(Math.abs(j) + 100).substring(1);
ZoneOffset test = ZoneOffset.of(str);
doTestOffset(test, i, j, 0);
}
}
}
ZoneOffset test1 = ZoneOffset.of("-18:00");
doTestOffset(test1, -18, 0, 0);
ZoneOffset test2 = ZoneOffset.of("+18:00");
doTestOffset(test2, 18, 0, 0);
}
use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.
the class TCKZoneOffset method test_factory_string_singleDigitHours.
//-----------------------------------------------------------------------
@Test
public void test_factory_string_singleDigitHours() {
for (int i = -9; i <= 9; i++) {
String str = (i < 0 ? "-" : "+") + Math.abs(i);
ZoneOffset test = ZoneOffset.of(str);
doTestOffset(test, i, 0, 0);
}
}
use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.
the class TCKZoneOffset method test_factory_int_hours_minutes.
//-----------------------------------------------------------------------
@Test
public void test_factory_int_hours_minutes() {
for (int i = -17; i <= 17; i++) {
for (int j = -59; j <= 59; j++) {
if ((i < 0 && j <= 0) || (i > 0 && j >= 0) || i == 0) {
ZoneOffset test = ZoneOffset.ofHoursMinutes(i, j);
doTestOffset(test, i, j, 0);
}
}
}
ZoneOffset test1 = ZoneOffset.ofHoursMinutes(-18, 0);
doTestOffset(test1, -18, 0, 0);
ZoneOffset test2 = ZoneOffset.ofHoursMinutes(18, 0);
doTestOffset(test2, 18, 0, 0);
}
use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.
the class TCKZoneOffset method test_adjustInto_ZonedDateTime.
//-----------------------------------------------------------------------
// adjustInto()
//-----------------------------------------------------------------------
@Test
public void test_adjustInto_ZonedDateTime() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
for (String zoneId : ZoneId.getAvailableZoneIds()) {
//Do not change offset of ZonedDateTime after adjustInto()
ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
ZonedDateTime zonedDateTime_result = (ZonedDateTime) (base.adjustInto(zonedDateTime_target));
assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());
OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
OffsetDateTime offsetDateTime_result = (OffsetDateTime) (base.adjustInto(offsetDateTime_target));
assertEquals(base, offsetDateTime_result.getOffset());
}
}
use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.
the class TCKZoneOffset method test_factory_string_hours_minutes_seconds_noColon.
@Test
public void test_factory_string_hours_minutes_seconds_noColon() {
for (int i = -17; i <= 17; i++) {
for (int j = -59; j <= 59; j++) {
for (int k = -59; k <= 59; k++) {
if ((i < 0 && j <= 0 && k <= 0) || (i > 0 && j >= 0 && k >= 0) || (i == 0 && ((j < 0 && k <= 0) || (j > 0 && k >= 0) || j == 0))) {
String str = (i < 0 || j < 0 || k < 0 ? "-" : "+") + Integer.toString(Math.abs(i) + 100).substring(1) + Integer.toString(Math.abs(j) + 100).substring(1) + Integer.toString(Math.abs(k) + 100).substring(1);
ZoneOffset test = ZoneOffset.of(str);
doTestOffset(test, i, j, k);
}
}
}
}
ZoneOffset test1 = ZoneOffset.of("-180000");
doTestOffset(test1, -18, 0, 0);
ZoneOffset test2 = ZoneOffset.of("+180000");
doTestOffset(test2, 18, 0, 0);
}
Aggregations