Package java.time

Examples of java.time.ZoneId


  public void testIsValid() {
    assertTrue( constraint.isValid( null, null ), "null fails validation." );

    // Test allowed zone offsets (UTC-18 to UTC+18) with 1 hour increments
    for ( int i = -18; i <= 18; i++ ) {
      ZoneId zone = ZoneId.ofOffset( "UTC", ZoneOffset.ofHours( i ) );
      ChronoZonedDateTime future = ZonedDateTime.now( zone ).plusHours( 1 );
      ChronoZonedDateTime past = ZonedDateTime.now( zone ).minusHours( 1 );
      assertTrue( constraint.isValid( past, null ), "Past ZonedDateTime '" + past + "' fails validation.");
      assertFalse( constraint.isValid( future, null ), "Future ZonedDateTime '" + future + "' validated as past.");
    }
View Full Code Here


  public void testIsValid() {
    assertTrue( constraint.isValid( null, null ), "null fails validation." );

    // Test allowed zone offsets (UTC-18 to UTC+18) with 1 hour increments
    for ( int i = -18; i <= 18; i++ ) {
      ZoneId zone = ZoneId.ofOffset( "UTC", ZoneOffset.ofHours( i ) );
      ChronoZonedDateTime future = ZonedDateTime.now( zone ).plusHours( 1 );
      ChronoZonedDateTime past = ZonedDateTime.now( zone ).minusHours( 1 );
      assertTrue( constraint.isValid( future, null ), "Future ZonedDateTime '" + future + "' fails validation." );
      assertFalse( constraint.isValid( past, null ), "Past ZonedDateTime '" + past + "' validated as future." );
    }
View Full Code Here

        Instant instant = clock.instant();
        Date legacyDate = Date.from(instant);


        ZoneId zone1 = ZoneId.of("Europe/Berlin");
        ZoneId zone2 = ZoneId.of("Brazil/East");

        System.out.println(zone1.getRules());
        System.out.println(zone2.getRules());

        // time
        LocalTime now1 = LocalTime.now(zone1);
        LocalTime now2 = LocalTime.now(zone2);
View Full Code Here

   */
  @Test
  public void testZoneIdRegionAndFixedOffset() {
    // Create zoned date/time using ZoneId to parse an IANA area/region format TZ ID (use one that doesn't vary with
    // daylight saving to ensure this test-case is stable)
    final ZoneId zoneId = ZoneId.of("Africa/Addis_Ababa");
    final ZonedDateTime zonedDateTime = ZonedDateTime.of(2014, Month.AUGUST.getValue(), 30, 21, 40, 20, 0, zoneId);

    // Use ZoneOffset to return the fixed offset of a zoned date/time from UTC
    final ZoneOffset zoneOffset = zonedDateTime.getOffset();
    int threeHoursInSeconds = 3 * 60 * 60;
 
View Full Code Here

TOP

Related Classes of java.time.ZoneId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.