예제 #1
0
 protected void gwtSetUp() throws Exception {
   super.gwtSetUp();
   DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
   originalDateTimeZone = DateTimeZone.getDefault();
   /* //BEGIN GWT IGNORE
   originalTimeZone = TimeZone.getDefault();
   originalLocale = Locale.getDefault();
   //END GWT IGNORE */
   DateTimeZone.setDefault(LONDON);
   /* //BEGIN GWT IGNORE
   //TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   //Locale.setDefault(Locale.UK);
   TimeZone.setDefault(DateTimeZone.forID("Asia/Tokyo").toTimeZone());
   Locale.setDefault(Locale.JAPAN);
   //END GWT IGNORE */
 }
예제 #2
0
 protected void gwtTearDown() throws Exception {
   super.gwtTearDown();
   DateTimeUtils.setCurrentMillisSystem();
   DateTimeZone.setDefault(originalDateTimeZone);
   /* //BEGIN GWT IGNORE
   TimeZone.setDefault(originalTimeZone);
   Locale.setDefault(originalLocale);
   //END GWT IGNORE */
   originalDateTimeZone = null;
 }
예제 #3
0
  // -----------------------------------------------------------------------
  public void testDurationFields() {
    assertEquals("eras", ISOChronology.getInstance().eras().getName());
    assertEquals("centuries", ISOChronology.getInstance().centuries().getName());
    assertEquals("years", ISOChronology.getInstance().years().getName());
    assertEquals("weekyears", ISOChronology.getInstance().weekyears().getName());
    assertEquals("months", ISOChronology.getInstance().months().getName());
    assertEquals("weeks", ISOChronology.getInstance().weeks().getName());
    assertEquals("days", ISOChronology.getInstance().days().getName());
    assertEquals("halfdays", ISOChronology.getInstance().halfdays().getName());
    assertEquals("hours", ISOChronology.getInstance().hours().getName());
    assertEquals("minutes", ISOChronology.getInstance().minutes().getName());
    assertEquals("seconds", ISOChronology.getInstance().seconds().getName());
    assertEquals("millis", ISOChronology.getInstance().millis().getName());

    assertEquals(false, ISOChronology.getInstance().eras().isSupported());
    assertEquals(true, ISOChronology.getInstance().centuries().isSupported());
    assertEquals(true, ISOChronology.getInstance().years().isSupported());
    assertEquals(true, ISOChronology.getInstance().weekyears().isSupported());
    assertEquals(true, ISOChronology.getInstance().months().isSupported());
    assertEquals(true, ISOChronology.getInstance().weeks().isSupported());
    assertEquals(true, ISOChronology.getInstance().days().isSupported());
    assertEquals(true, ISOChronology.getInstance().halfdays().isSupported());
    assertEquals(true, ISOChronology.getInstance().hours().isSupported());
    assertEquals(true, ISOChronology.getInstance().minutes().isSupported());
    assertEquals(true, ISOChronology.getInstance().seconds().isSupported());
    assertEquals(true, ISOChronology.getInstance().millis().isSupported());

    assertEquals(false, ISOChronology.getInstance().centuries().isPrecise());
    assertEquals(false, ISOChronology.getInstance().years().isPrecise());
    assertEquals(false, ISOChronology.getInstance().weekyears().isPrecise());
    assertEquals(false, ISOChronology.getInstance().months().isPrecise());
    assertEquals(false, ISOChronology.getInstance().weeks().isPrecise());
    assertEquals(false, ISOChronology.getInstance().days().isPrecise());
    assertEquals(false, ISOChronology.getInstance().halfdays().isPrecise());
    assertEquals(true, ISOChronology.getInstance().hours().isPrecise());
    assertEquals(true, ISOChronology.getInstance().minutes().isPrecise());
    assertEquals(true, ISOChronology.getInstance().seconds().isPrecise());
    assertEquals(true, ISOChronology.getInstance().millis().isPrecise());

    assertEquals(false, ISOChronology.getInstanceUTC().centuries().isPrecise());
    assertEquals(false, ISOChronology.getInstanceUTC().years().isPrecise());
    assertEquals(false, ISOChronology.getInstanceUTC().weekyears().isPrecise());
    assertEquals(false, ISOChronology.getInstanceUTC().months().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().weeks().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().days().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().halfdays().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().hours().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().minutes().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().seconds().isPrecise());
    assertEquals(true, ISOChronology.getInstanceUTC().millis().isPrecise());

    DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
    assertEquals(false, ISOChronology.getInstance(gmt).centuries().isPrecise());
    assertEquals(false, ISOChronology.getInstance(gmt).years().isPrecise());
    assertEquals(false, ISOChronology.getInstance(gmt).weekyears().isPrecise());
    assertEquals(false, ISOChronology.getInstance(gmt).months().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).weeks().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).days().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).halfdays().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).hours().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).minutes().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).seconds().isPrecise());
    assertEquals(true, ISOChronology.getInstance(gmt).millis().isPrecise());

    DateTimeZone offset = DateTimeZone.forOffsetHours(1);
    assertEquals(false, ISOChronology.getInstance(offset).centuries().isPrecise());
    assertEquals(false, ISOChronology.getInstance(offset).years().isPrecise());
    assertEquals(false, ISOChronology.getInstance(offset).weekyears().isPrecise());
    assertEquals(false, ISOChronology.getInstance(offset).months().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).weeks().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).days().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).halfdays().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).hours().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).minutes().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).seconds().isPrecise());
    assertEquals(true, ISOChronology.getInstance(offset).millis().isPrecise());
  }