本文整理匯總了Java中java.time.ZoneId.systemDefault方法的典型用法代碼示例。如果您正苦於以下問題:Java ZoneId.systemDefault方法的具體用法?Java ZoneId.systemDefault怎麽用?Java ZoneId.systemDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.ZoneId
的用法示例。
在下文中一共展示了ZoneId.systemDefault方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testZonedDateTime
import java.time.ZoneId; //導入方法依賴的package包/類
@Test()
public void testZonedDateTime() {
final int count = 10;
final Random random = new Random();
final Array<ZonedDateTime> array1 = Array.map(ZonedDateTime.class, count, null);
final ZonedDateTime[] array2 = new ZonedDateTime[count];
for (int i=0; i<count; ++i) {
final ZoneId zoneId = i % 2 == 0 ? ZoneId.of("UTC") : ZoneId.systemDefault();
final ZonedDateTime value = ZonedDateTime.now().minusMinutes(random.nextInt(100)).withZoneSameInstant(zoneId);
array1.setValue(i, value);
array2[i] = value;
}
for (int i=0; i<count; ++i) {
final ZonedDateTime v1 = array1.getValue(i);
final ZonedDateTime v2 = array2[i];
Assert.assertEquals(v1, v2);
System.out.println(v1);
}
}
示例2: test_systemDefault_unableToConvert_badFormat
import java.time.ZoneId; //導入方法依賴的package包/類
@Test(expectedExceptions = DateTimeException.class)
public void test_systemDefault_unableToConvert_badFormat() {
TimeZone current = TimeZone.getDefault();
try {
TimeZone.setDefault(new SimpleTimeZone(127, "Something Weird"));
ZoneId.systemDefault();
} finally {
TimeZone.setDefault(current);
}
}
示例3: test_systemDefault_unableToConvert_unknownId
import java.time.ZoneId; //導入方法依賴的package包/類
@Test(expectedExceptions = ZoneRulesException.class)
public void test_systemDefault_unableToConvert_unknownId() {
TimeZone current = TimeZone.getDefault();
try {
TimeZone.setDefault(new SimpleTimeZone(127, "SomethingWeird"));
ZoneId.systemDefault();
} finally {
TimeZone.setDefault(current);
}
}
示例4: shouldFailBecauseOfBadTimes
import java.time.ZoneId; //導入方法依賴的package包/類
@Test(expected = IllegalArgumentException.class)
public void shouldFailBecauseOfBadTimes() {
// given
LocalDate startDate = LocalDate.now();
LocalDate endDate = startDate;
// when
new Interval(startDate, LocalTime.now(), endDate, LocalTime.now().minusHours(1), ZoneId.systemDefault());
// then
// throw exception
}
示例5: TestEntityDate
import java.time.ZoneId; //導入方法依賴的package包/類
public TestEntityDate(final long millis) {
super();
instant = Instant.ofEpochMilli(millis);
localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
zonedDateTime = instant.atZone(ZoneId.systemDefault());
offsetDateTime = instant.atOffset(ZoneId.systemDefault().getRules().getOffset(instant));
zoneId = ZoneId.systemDefault();
}
示例6: parseDate
import java.time.ZoneId; //導入方法依賴的package包/類
public static String parseDate(Date date) {
Instant instant = date.toInstant();
ZoneId zone = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
return formaterLocalDateTime(localDateTime);
}
示例7: getZoneId
import java.time.ZoneId; //導入方法依賴的package包/類
public static ZoneId getZoneId() {
if (ZONE_ID == null) {
ZONE_ID = ZoneId.systemDefault();
}
return ZONE_ID;
}
示例8: DateToLocalDateTimeConverter
import java.time.ZoneId; //導入方法依賴的package包/類
/**
* Construct a converter using given Time Zone
* @param timeZone Time zone to use for conversion
*/
public DateToLocalDateTimeConverter(ZoneId timeZone) {
super();
this.timeZone = (timeZone != null) ? timeZone : ZoneId.systemDefault();
}
示例9: getZoneId
import java.time.ZoneId; //導入方法依賴的package包/類
public static final ZoneId getZoneId() {
return ZONE_ID == null ? ZoneId.systemDefault() : ZONE_ID;
}
示例10: getDateYYYY
import java.time.ZoneId; //導入方法依賴的package包/類
public static Date getDateYYYY() throws ParseException{
LocalDateTime localDateTime = parseLocalDateTime(getCurrentDateTime());
ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant();
return Date.from(instant);
}
示例11: Axis
import java.time.ZoneId; //導入方法依賴的package包/類
public Axis(final double MIN_VALUE, final double MAX_VALUE, final Orientation ORIENTATION, final AxisType TYPE, final Position POSITION, final String TITLE) {
if (VERTICAL == ORIENTATION) {
if (Position.LEFT != POSITION && Position.RIGHT != POSITION && Position.CENTER != POSITION) {
throw new IllegalArgumentException("Wrong combination of orientation and position!");
}
} else {
if (Position.TOP != POSITION && Position.BOTTOM != POSITION && Position.CENTER != POSITION) {
throw new IllegalArgumentException("Wrong combination of orientation and position!");
}
}
_minValue = MIN_VALUE;
_maxValue = MAX_VALUE;
_type = TYPE;
_autoScale = true;
_title = TITLE;
_unit = "";
_orientation = ORIENTATION;
_position = POSITION;
_axisBackgroundColor = Color.TRANSPARENT;
_axisColor = Color.BLACK;
_tickLabelColor = Color.BLACK;
_titleColor = Color.BLACK;
_minorTickMarkColor = Color.BLACK;
_mediumTickMarkColor = Color.BLACK;
_majorTickMarkColor = Color.BLACK;
_zeroColor = Color.BLACK;
_zeroPosition = 0;
_minorTickSpace = 1;
_majorTickSpace = 10;
_majorTickMarksVisible = true;
_mediumTickMarksVisible = true;
_minorTickMarksVisible = true;
_tickLabelsVisible = true;
_onlyFirstAndLastTickLabelVisible = false;
_locale = Locale.US;
_decimals = 0;
_tickLabelOrientation = TickLabelOrientation.HORIZONTAL;
_tickLabelFormat = TickLabelFormat.NUMBER;
_autoFontSize = true;
_tickLabelFontSize = 10;
_titleFontSize = 10;
_zoneId = ZoneId.systemDefault();
_dateTimeFormatPattern = "dd.MM.YY HH:mm:ss";
currentInterval = Interval.SECOND_1;
dateTimeFormatter = DateTimeFormatter.ofPattern(_dateTimeFormatPattern, _locale);
categories = new LinkedList<>();
tickLabelFormatString = new StringBuilder("%.").append(Integer.toString(_decimals)).append("f").toString();
initGraphics();
registerListeners();
}
示例12: test_systemDefault
import java.time.ZoneId; //導入方法依賴的package包/類
public void test_systemDefault() {
ZoneId test = ZoneId.systemDefault();
assertEquals(test.getId(), TimeZone.getDefault().getID());
}
示例13: getZoneId
import java.time.ZoneId; //導入方法依賴的package包/類
@Override
public ZoneId getZoneId() {
return ZoneId.systemDefault();
}
示例14: findOneByJsr310Types
import java.time.ZoneId; //導入方法依賴的package包/類
@Test
public void findOneByJsr310Types() {
Order order = new Order("42", LocalDate.now(), ZoneId.systemDefault());
repository.save(order);
assertThat(repository.findOrderByOrderDateAndZoneId(order.getOrderDate(), order.getZoneId()), is(equalTo(order)));
}
示例15: findOneByConvertedTypes
import java.time.ZoneId; //導入方法依賴的package包/類
@Test
public void findOneByConvertedTypes() {
Order order = new Order("42", LocalDate.of(2010, 1, 2), ZoneId.systemDefault());
repository.save(order);
com.datastax.driver.core.LocalDate date = com.datastax.driver.core.LocalDate.fromYearMonthDay(2010, 1, 2);
String zoneId = order.getZoneId().getId();
assertThat(repository.findOrderByDate(date, zoneId), is(equalTo(order)));
}