當前位置: 首頁>>代碼示例>>Java>>正文


Java ZoneId.systemDefault方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:20,代碼來源:ArrayMappedTests.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TestZoneId.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TestZoneId.java

示例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
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:13,代碼來源:IntervalTest.java

示例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();
}
 
開發者ID:arangodb,項目名稱:java-velocypack-module-jdk8,代碼行數:10,代碼來源:VPackTimeTest.java

示例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);
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:7,代碼來源:DateUtils.java

示例7: getZoneId

import java.time.ZoneId; //導入方法依賴的package包/類
public static ZoneId getZoneId() {
  if (ZONE_ID == null) {
    ZONE_ID = ZoneId.systemDefault();
  }
  return ZONE_ID;
}
 
開發者ID:EHRI,項目名稱:rs-aggregator,代碼行數:7,代碼來源:ZonedDateTimeUtil.java

示例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();
}
 
開發者ID:holon-platform,項目名稱:holon-vaadin7,代碼行數:9,代碼來源:DateToLocalDateTimeConverter.java

示例9: getZoneId

import java.time.ZoneId; //導入方法依賴的package包/類
public static final ZoneId getZoneId() {
    return ZONE_ID == null ? ZoneId.systemDefault() : ZONE_ID;
}
 
開發者ID:Panzer1119,項目名稱:Supreme-Bot,代碼行數:4,代碼來源:Standard.java

示例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);
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:7,代碼來源:DateUtils.java

示例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();
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:54,代碼來源:Axis.java

示例12: test_systemDefault

import java.time.ZoneId; //導入方法依賴的package包/類
public void test_systemDefault() {
    ZoneId test = ZoneId.systemDefault();
    assertEquals(test.getId(), TimeZone.getDefault().getID());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TestZoneId.java

示例13: getZoneId

import java.time.ZoneId; //導入方法依賴的package包/類
@Override
public ZoneId getZoneId() {
    return ZoneId.systemDefault();
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:5,代碼來源:AgendaViewSkin.java

示例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)));
}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:10,代碼來源:Jsr310IntegrationTests.java

示例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)));
}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:13,代碼來源:Jsr310IntegrationTests.java


注:本文中的java.time.ZoneId.systemDefault方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。