Search in sources :

Example 91 with DateTimeZone

use of org.joda.time.DateTimeZone in project joda-time by JodaOrg.

the class TestGregorianChronology method testDurationFields.

//-----------------------------------------------------------------------
public void testDurationFields() {
    final GregorianChronology greg = GregorianChronology.getInstance();
    assertEquals("eras", greg.eras().getName());
    assertEquals("centuries", greg.centuries().getName());
    assertEquals("years", greg.years().getName());
    assertEquals("weekyears", greg.weekyears().getName());
    assertEquals("months", greg.months().getName());
    assertEquals("weeks", greg.weeks().getName());
    assertEquals("days", greg.days().getName());
    assertEquals("halfdays", greg.halfdays().getName());
    assertEquals("hours", greg.hours().getName());
    assertEquals("minutes", greg.minutes().getName());
    assertEquals("seconds", greg.seconds().getName());
    assertEquals("millis", greg.millis().getName());
    assertEquals(false, greg.eras().isSupported());
    assertEquals(true, greg.centuries().isSupported());
    assertEquals(true, greg.years().isSupported());
    assertEquals(true, greg.weekyears().isSupported());
    assertEquals(true, greg.months().isSupported());
    assertEquals(true, greg.weeks().isSupported());
    assertEquals(true, greg.days().isSupported());
    assertEquals(true, greg.halfdays().isSupported());
    assertEquals(true, greg.hours().isSupported());
    assertEquals(true, greg.minutes().isSupported());
    assertEquals(true, greg.seconds().isSupported());
    assertEquals(true, greg.millis().isSupported());
    assertEquals(false, greg.centuries().isPrecise());
    assertEquals(false, greg.years().isPrecise());
    assertEquals(false, greg.weekyears().isPrecise());
    assertEquals(false, greg.months().isPrecise());
    assertEquals(false, greg.weeks().isPrecise());
    assertEquals(false, greg.days().isPrecise());
    assertEquals(false, greg.halfdays().isPrecise());
    assertEquals(true, greg.hours().isPrecise());
    assertEquals(true, greg.minutes().isPrecise());
    assertEquals(true, greg.seconds().isPrecise());
    assertEquals(true, greg.millis().isPrecise());
    final GregorianChronology gregUTC = GregorianChronology.getInstanceUTC();
    assertEquals(false, gregUTC.centuries().isPrecise());
    assertEquals(false, gregUTC.years().isPrecise());
    assertEquals(false, gregUTC.weekyears().isPrecise());
    assertEquals(false, gregUTC.months().isPrecise());
    assertEquals(true, gregUTC.weeks().isPrecise());
    assertEquals(true, gregUTC.days().isPrecise());
    assertEquals(true, gregUTC.halfdays().isPrecise());
    assertEquals(true, gregUTC.hours().isPrecise());
    assertEquals(true, gregUTC.minutes().isPrecise());
    assertEquals(true, gregUTC.seconds().isPrecise());
    assertEquals(true, gregUTC.millis().isPrecise());
    final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
    final GregorianChronology gregGMT = GregorianChronology.getInstance(gmt);
    assertEquals(false, gregGMT.centuries().isPrecise());
    assertEquals(false, gregGMT.years().isPrecise());
    assertEquals(false, gregGMT.weekyears().isPrecise());
    assertEquals(false, gregGMT.months().isPrecise());
    assertEquals(true, gregGMT.weeks().isPrecise());
    assertEquals(true, gregGMT.days().isPrecise());
    assertEquals(true, gregGMT.halfdays().isPrecise());
    assertEquals(true, gregGMT.hours().isPrecise());
    assertEquals(true, gregGMT.minutes().isPrecise());
    assertEquals(true, gregGMT.seconds().isPrecise());
    assertEquals(true, gregGMT.millis().isPrecise());
}
Also used : DateTimeZone(org.joda.time.DateTimeZone)

Example 92 with DateTimeZone

use of org.joda.time.DateTimeZone in project joda-time by JodaOrg.

the class TestISOChronology method testDurationFields.

//-----------------------------------------------------------------------
public void testDurationFields() {
    final ISOChronology iso = ISOChronology.getInstance();
    assertEquals("eras", iso.eras().getName());
    assertEquals("centuries", iso.centuries().getName());
    assertEquals("years", iso.years().getName());
    assertEquals("weekyears", iso.weekyears().getName());
    assertEquals("months", iso.months().getName());
    assertEquals("weeks", iso.weeks().getName());
    assertEquals("days", iso.days().getName());
    assertEquals("halfdays", iso.halfdays().getName());
    assertEquals("hours", iso.hours().getName());
    assertEquals("minutes", iso.minutes().getName());
    assertEquals("seconds", iso.seconds().getName());
    assertEquals("millis", iso.millis().getName());
    assertEquals(false, iso.eras().isSupported());
    assertEquals(true, iso.centuries().isSupported());
    assertEquals(true, iso.years().isSupported());
    assertEquals(true, iso.weekyears().isSupported());
    assertEquals(true, iso.months().isSupported());
    assertEquals(true, iso.weeks().isSupported());
    assertEquals(true, iso.days().isSupported());
    assertEquals(true, iso.halfdays().isSupported());
    assertEquals(true, iso.hours().isSupported());
    assertEquals(true, iso.minutes().isSupported());
    assertEquals(true, iso.seconds().isSupported());
    assertEquals(true, iso.millis().isSupported());
    assertEquals(false, iso.centuries().isPrecise());
    assertEquals(false, iso.years().isPrecise());
    assertEquals(false, iso.weekyears().isPrecise());
    assertEquals(false, iso.months().isPrecise());
    assertEquals(false, iso.weeks().isPrecise());
    assertEquals(false, iso.days().isPrecise());
    assertEquals(false, iso.halfdays().isPrecise());
    assertEquals(true, iso.hours().isPrecise());
    assertEquals(true, iso.minutes().isPrecise());
    assertEquals(true, iso.seconds().isPrecise());
    assertEquals(true, iso.millis().isPrecise());
    final ISOChronology isoUTC = ISOChronology.getInstanceUTC();
    assertEquals(false, isoUTC.centuries().isPrecise());
    assertEquals(false, isoUTC.years().isPrecise());
    assertEquals(false, isoUTC.weekyears().isPrecise());
    assertEquals(false, isoUTC.months().isPrecise());
    assertEquals(true, isoUTC.weeks().isPrecise());
    assertEquals(true, isoUTC.days().isPrecise());
    assertEquals(true, isoUTC.halfdays().isPrecise());
    assertEquals(true, isoUTC.hours().isPrecise());
    assertEquals(true, isoUTC.minutes().isPrecise());
    assertEquals(true, isoUTC.seconds().isPrecise());
    assertEquals(true, isoUTC.millis().isPrecise());
    final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
    final ISOChronology isoGMT = ISOChronology.getInstance(gmt);
    assertEquals(false, isoGMT.centuries().isPrecise());
    assertEquals(false, isoGMT.years().isPrecise());
    assertEquals(false, isoGMT.weekyears().isPrecise());
    assertEquals(false, isoGMT.months().isPrecise());
    assertEquals(true, isoGMT.weeks().isPrecise());
    assertEquals(true, isoGMT.days().isPrecise());
    assertEquals(true, isoGMT.halfdays().isPrecise());
    assertEquals(true, isoGMT.hours().isPrecise());
    assertEquals(true, isoGMT.minutes().isPrecise());
    assertEquals(true, isoGMT.seconds().isPrecise());
    assertEquals(true, isoGMT.millis().isPrecise());
    final DateTimeZone offset = DateTimeZone.forOffsetHours(1);
    final ISOChronology isoOffset1 = ISOChronology.getInstance(offset);
    assertEquals(false, isoOffset1.centuries().isPrecise());
    assertEquals(false, isoOffset1.years().isPrecise());
    assertEquals(false, isoOffset1.weekyears().isPrecise());
    assertEquals(false, isoOffset1.months().isPrecise());
    assertEquals(true, isoOffset1.weeks().isPrecise());
    assertEquals(true, isoOffset1.days().isPrecise());
    assertEquals(true, isoOffset1.halfdays().isPrecise());
    assertEquals(true, isoOffset1.hours().isPrecise());
    assertEquals(true, isoOffset1.minutes().isPrecise());
    assertEquals(true, isoOffset1.seconds().isPrecise());
    assertEquals(true, isoOffset1.millis().isPrecise());
}
Also used : DateTimeZone(org.joda.time.DateTimeZone)

Example 93 with DateTimeZone

use of org.joda.time.DateTimeZone in project joda-time by JodaOrg.

the class TestGJChronology method testDurationFields.

//-----------------------------------------------------------------------
public void testDurationFields() {
    final GJChronology gj = GJChronology.getInstance();
    assertEquals("eras", gj.eras().getName());
    assertEquals("centuries", gj.centuries().getName());
    assertEquals("years", gj.years().getName());
    assertEquals("weekyears", gj.weekyears().getName());
    assertEquals("months", gj.months().getName());
    assertEquals("weeks", gj.weeks().getName());
    assertEquals("halfdays", gj.halfdays().getName());
    assertEquals("days", gj.days().getName());
    assertEquals("hours", gj.hours().getName());
    assertEquals("minutes", gj.minutes().getName());
    assertEquals("seconds", gj.seconds().getName());
    assertEquals("millis", gj.millis().getName());
    assertEquals(false, gj.eras().isSupported());
    assertEquals(true, gj.centuries().isSupported());
    assertEquals(true, gj.years().isSupported());
    assertEquals(true, gj.weekyears().isSupported());
    assertEquals(true, gj.months().isSupported());
    assertEquals(true, gj.weeks().isSupported());
    assertEquals(true, gj.days().isSupported());
    assertEquals(true, gj.halfdays().isSupported());
    assertEquals(true, gj.hours().isSupported());
    assertEquals(true, gj.minutes().isSupported());
    assertEquals(true, gj.seconds().isSupported());
    assertEquals(true, gj.millis().isSupported());
    assertEquals(false, gj.centuries().isPrecise());
    assertEquals(false, gj.years().isPrecise());
    assertEquals(false, gj.weekyears().isPrecise());
    assertEquals(false, gj.months().isPrecise());
    assertEquals(false, gj.weeks().isPrecise());
    assertEquals(false, gj.days().isPrecise());
    assertEquals(false, gj.halfdays().isPrecise());
    assertEquals(true, gj.hours().isPrecise());
    assertEquals(true, gj.minutes().isPrecise());
    assertEquals(true, gj.seconds().isPrecise());
    assertEquals(true, gj.millis().isPrecise());
    final GJChronology gjUTC = GJChronology.getInstanceUTC();
    assertEquals(false, gjUTC.centuries().isPrecise());
    assertEquals(false, gjUTC.years().isPrecise());
    assertEquals(false, gjUTC.weekyears().isPrecise());
    assertEquals(false, gjUTC.months().isPrecise());
    assertEquals(true, gjUTC.weeks().isPrecise());
    assertEquals(true, gjUTC.days().isPrecise());
    assertEquals(true, gjUTC.halfdays().isPrecise());
    assertEquals(true, gjUTC.hours().isPrecise());
    assertEquals(true, gjUTC.minutes().isPrecise());
    assertEquals(true, gjUTC.seconds().isPrecise());
    assertEquals(true, gjUTC.millis().isPrecise());
    final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
    final GJChronology gjGMT = GJChronology.getInstance(gmt);
    assertEquals(false, gjGMT.centuries().isPrecise());
    assertEquals(false, gjGMT.years().isPrecise());
    assertEquals(false, gjGMT.weekyears().isPrecise());
    assertEquals(false, gjGMT.months().isPrecise());
    assertEquals(true, gjGMT.weeks().isPrecise());
    assertEquals(true, gjGMT.days().isPrecise());
    assertEquals(true, gjGMT.halfdays().isPrecise());
    assertEquals(true, gjGMT.hours().isPrecise());
    assertEquals(true, gjGMT.minutes().isPrecise());
    assertEquals(true, gjGMT.seconds().isPrecise());
    assertEquals(true, gjGMT.millis().isPrecise());
}
Also used : DateTimeZone(org.joda.time.DateTimeZone)

Example 94 with DateTimeZone

use of org.joda.time.DateTimeZone in project OpenClinica by OpenClinica.

the class OpenClinicaBeanVariableNode method testCalculateVariable.

private String testCalculateVariable() {
    if (number.equals("_CURRENT_DATE")) {
        String ssTimeZone = getExpressionBeanService().getSSTimeZone();
        if (ssTimeZone.equals("") || ssTimeZone == null)
            ssTimeZone = TimeZone.getDefault().getID();
        DateTimeZone ssZone = DateTimeZone.forID(ssTimeZone);
        DateMidnight dm = new DateMidnight(ssZone);
        DateTimeFormatter fmt = ISODateTimeFormat.date();
        return fmt.print(dm);
    }
    return null;
}
Also used : DateMidnight(org.joda.time.DateMidnight) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeZone(org.joda.time.DateTimeZone)

Example 95 with DateTimeZone

use of org.joda.time.DateTimeZone in project OpenClinica by OpenClinica.

the class ExpressionService method getSSDate.

public HashMap<String, String> getSSDate(String ssZoneId, String serverZoneId) {
    HashMap<String, String> map = new HashMap<String, String>();
    if (ssZoneId == null || ssZoneId.equals(""))
        ssZoneId = TimeZone.getDefault().getID();
    DateTimeZone ssZone = DateTimeZone.forID(ssZoneId);
    DateMidnight dm = new DateMidnight(ssZone);
    DateTimeFormatter fmt = ISODateTimeFormat.date();
    map.put("ssDate", fmt.print(dm));
    map.put("serverZoneId", serverZoneId);
    DateTimeZone serverZone = DateTimeZone.forID(serverZoneId);
    DateMidnight serverDate = new DateMidnight(serverZone);
    map.put("serverDate", fmt.print(serverDate));
    return map;
}
Also used : HashMap(java.util.HashMap) DateMidnight(org.joda.time.DateMidnight) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeZone(org.joda.time.DateTimeZone)

Aggregations

DateTimeZone (org.joda.time.DateTimeZone)263 DateTime (org.joda.time.DateTime)123 ArrayList (java.util.ArrayList)36 Test (org.testng.annotations.Test)35 LocalDate (org.joda.time.LocalDate)27 Test (org.junit.Test)21 TimeIntervalRounding (org.elasticsearch.common.rounding.Rounding.TimeIntervalRounding)18 TimeUnitRounding (org.elasticsearch.common.rounding.Rounding.TimeUnitRounding)18 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)17 IOException (java.io.IOException)16 HashMap (java.util.HashMap)15 UUID (java.util.UUID)14 TimeFormat (org.gephi.graph.api.TimeFormat)13 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)12 Date (java.util.Date)12 Chronology (org.joda.time.Chronology)12 LocalDateTime (org.joda.time.LocalDateTime)12 DefaultBlockingState (org.killbill.billing.junction.DefaultBlockingState)11 LocalTime (org.joda.time.LocalTime)10 SubscriptionBaseTransition (org.killbill.billing.subscription.api.user.SubscriptionBaseTransition)10