当前位置: 首页>>代码示例>>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;未经允许,请勿转载。