Package java.util

Examples of java.util.SimpleTimeZone


   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)
  {
    SimpleTimeZone z1 = new SimpleTimeZone(5 * 60 * 60 * 1000, "Zone 1",
      Calendar.APRIL, 26, 0, 2*60*60*1000,
      Calendar.OCTOBER, 25, 0, 2*60*60*1000, 36000000);
    harness.check(z1.getDSTSavings(), 36000000);
    z1.setDSTSavings(12345);
    harness.check(z1.getDSTSavings(), 12345);
  }
View Full Code Here


    c1.setMinimalDaysInFirstWeek(6);
    harness.check(!c1.equals(c2));
    c2.setMinimalDaysInFirstWeek(6);
    harness.check(c1.equals(c2));

    c1.setTimeZone(new SimpleTimeZone(123, "123"));
    harness.check(!c1.equals(c2));
    c2.setTimeZone(new SimpleTimeZone(123, "123"));
    harness.check(c1.equals(c2));
  }
View Full Code Here

  }

  public void test_DST (TestHarness harness)
  {
    // Create a custom TimeZone with a daylight-time period.
    SimpleTimeZone stz = new SimpleTimeZone(60 * 60 * 1000, "MyZone",
        Calendar.MARCH, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000,
        Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

    // Register the timezone as the default:
    TimeZone.setDefault(stz);
View Full Code Here

  {
    int offset = -6 * 60 * 60 * 1000;
    int t1 = 5 * 60 * 60 * 1000;
    int t2 = 6 * 60 * 60 * 1000;
    int dst = 2 * 60 * 60 * 1000;
    SimpleTimeZone z = new SimpleTimeZone(offset, "Z1",
      Calendar.APRIL, 26, 0, t1,
      Calendar.OCTOBER, 25, 0, t2, dst);
    z.setStartYear(2010);
   
    // the following checks are copied from the inDaylightTime test
    // but in this case the expected result is always false because
    // the start year has been set to 2010.
    GregorianCalendar c = new GregorianCalendar(z);
    c.set(2004, Calendar.APRIL, 25, 8, 0, 0);
    harness.check(!z.inDaylightTime(c.getTime()));
    c.set(2004, Calendar.APRIL, 26, 8, 0, 0);
    harness.check(!z.inDaylightTime(c.getTime()));
   
    c.set(2004, Calendar.OCTOBER, 24, 8, 0, 0);
    harness.check(!z.inDaylightTime(c.getTime()));
    c.set(2004, Calendar.OCTOBER, 25, 8, 0, 0);
    harness.check(!z.inDaylightTime(c.getTime()));
   
  }
View Full Code Here

    harness.checkPoint("(int, int, int, int, int, int)");
    int offset = -6 * 60 * 60 * 1000;
    int t1 = 5 * 60 * 60 * 1000;
    int t2 = 6 * 60 * 60 * 1000;
    int dst = 2 * 60 * 60 * 1000;
    SimpleTimeZone z = new SimpleTimeZone(offset, "Z1",
      Calendar.APRIL, 26, 0, t1,
      Calendar.OCTOBER, 25, 0, t2, dst);
    harness.check(z.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 26, Calendar.MONDAY, t1 - 1000), offset);
    harness.check(z.getOffset(GregorianCalendar.AD, 2004, Calendar.APRIL, 26, Calendar.MONDAY, t1 + 1000), offset + dst);
    harness.check(z.getOffset(GregorianCalendar.AD, 2004, Calendar.OCTOBER, 25, Calendar.MONDAY, t2 - dst - 1000), offset + dst);
    harness.check(z.getOffset(GregorianCalendar.AD, 2004, Calendar.OCTOBER, 25, Calendar.MONDAY, t2 - dst + 1000), offset);   
  }
View Full Code Here

    harness.checkPoint("(Date)");
    int offset = -6 * 60 * 60 * 1000;
    int t1 = 5 * 60 * 60 * 1000;
    int t2 = 6 * 60 * 60 * 1000;
    int dst = 2 * 60 * 60 * 1000;
    SimpleTimeZone z = new SimpleTimeZone(offset, "Z1",
      Calendar.APRIL, 26, 0, t1,
      Calendar.OCTOBER, 25, 0, t2, dst);
    GregorianCalendar c = new GregorianCalendar(z);
    c.set(2004, Calendar.APRIL, 26, 4, 59, 59);
    long d1 = c.getTimeInMillis();
    harness.check(z.getOffset(d1), offset);
    harness.check(z.getOffset(d1 + 2000), offset + dst);
   
    // to do : check end date 
  }
View Full Code Here

  // Tests converted from the SimpleTimeZoneTest.java attachment
  // of http://gcc.gnu.org/ml/java-patches/2007-q1/msg00587.html.
  private void test2(TestHarness harness)
  {
    TimeZone utc = (TimeZone) new SimpleTimeZone(0, "GMT");
    TimeZone.setDefault(utc);
    Calendar cal = Calendar.getInstance(utc);

    TimeZone tz2 = new SimpleTimeZone(
      -12600000, "Test1",
      Calendar.MARCH, 8, -Calendar.SUNDAY, 60000,
      SimpleTimeZone.WALL_TIME,
      Calendar.NOVEMBER, 1, -Calendar.SUNDAY, 60000,
      SimpleTimeZone.STANDARD_TIME,
      3600000);

    TimeZone tz3 = new SimpleTimeZone(
      -12600000, "Test2",
      Calendar.MARCH, 8, -Calendar.SUNDAY, 60000,
      Calendar.NOVEMBER, 1, -Calendar.SUNDAY, 3660000,
      3600000);
View Full Code Here

    test2(harness);
  }

  private void test1(TestHarness harness)
  {
    SimpleTimeZone z1 = new SimpleTimeZone(5 * 60 * 60 * 1000, "Z1");
    SimpleTimeZone z2 = new SimpleTimeZone(5 * 60 * 60 * 1000, "Z1");
  harness.check(z1.equals(z2));   
  harness.check(z1.hashCode(), z2.hashCode())
  }
View Full Code Here

  // Tests converted from the SimpleTimeZoneTest.java attachment
  // of http://gcc.gnu.org/ml/java-patches/2007-q1/msg00587.html.
  private void test2(TestHarness harness)
  {
    TimeZone utc = (TimeZone) new SimpleTimeZone(0, "GMT");
    TimeZone.setDefault(utc);
    Calendar cal = Calendar.getInstance(utc);

    TimeZone tz2 = new SimpleTimeZone(
      -12600000, "Test1",
      Calendar.MARCH, 8, -Calendar.SUNDAY, 60000,
      SimpleTimeZone.WALL_TIME,
      Calendar.NOVEMBER, 1, -Calendar.SUNDAY, 60000,
      SimpleTimeZone.STANDARD_TIME,
      3600000);

    TimeZone tz3 = new SimpleTimeZone(
      -12600000, "Test2",
      Calendar.MARCH, 8, -Calendar.SUNDAY, 60000,
      Calendar.NOVEMBER, 1, -Calendar.SUNDAY, 3660000,
      3600000);

    harness.check(tz2.hashCode() != tz3.hashCode());

    ((SimpleTimeZone) tz2).setEndRule(
      Calendar.NOVEMBER, 1, -Calendar.SUNDAY, 3660000);

    harness.check(tz2.hashCode() == tz3.hashCode());
  }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)
  {
    SimpleTimeZone z1 = new SimpleTimeZone(0, "Zone 1");
    z1.setRawOffset(12345);
    harness.check(z1.getRawOffset(), 12345);
  }
View Full Code Here

TOP

Related Classes of java.util.SimpleTimeZone

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.