Example usage for org.joda.time.chrono GJChronology getInstance

List of usage examples for org.joda.time.chrono GJChronology getInstance

Introduction

In this page you can find the example usage for org.joda.time.chrono GJChronology getInstance.

Prototype

public static GJChronology getInstance() 

Source Link

Document

Factory method returns instances of the default GJ cutover chronology.

Usage

From source file:com.helger.datetime.config.PDTConfig.java

License:Apache License

/**
 * @return The default chronology ({@link ISOChronology} or
 *         {@link GJChronology}) with the system date time zone. Never
 *         <code>null</code>.
 * @see #isUseISOChronology()/*from  w w  w .  j ava 2s.c o  m*/
 */
@Nonnull
public static Chronology getDefaultChronologyWithDefaultDateTimeZone() {
    if (isUseISOChronology())
        return ISOChronology.getInstance();
    return GJChronology.getInstance();
}

From source file:com.phloc.datetime.config.PDTConfig.java

License:Apache License

/**
 * @return The default chronology with the system date time zone
 *//*from w  w  w . j  av  a 2 s. c  o m*/
@Nonnull
public static Chronology getDefaultChronologyWithoutDateTimeZone() {
    if (s_bUseISOChronology)
        return ISOChronology.getInstance();
    return GJChronology.getInstance();
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaConstructor1() {
    int COUNT = COUNT_SLOW;
    DateTime dt = new DateTime(GJChronology.getInstance());
    int count = 0;
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "new()");
        for (int j = 0; j < COUNT; j++) {
            dt = new DateTime(GJChronology.getInstance());
            if (count++ < 0) {
                System.out.println("Anti optimise");
            }/*  w w w .ja v  a  2 s .c  o  m*/
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaConstructor2() {
    int COUNT = COUNT_VERY_FAST;
    DateTime dt = new DateTime(12345L, GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "new(millis)");
        for (int j = 0; j < COUNT; j++) {
            dt = new DateTime(12345L, GJChronology.getInstance());
            if (dt == null) {
                System.out.println("Anti optimise");
            }//from w w  w. j a v a  2s . com
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaConstructor3() {
    int COUNT = COUNT_SLOW;
    DateTime dt = new DateTime(1972, 10, 1, 0, 0, 0, 0, GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "new(YMD)");
        for (int j = 0; j < COUNT; j++) {
            dt = new DateTime(1972, 10, 1, 0, 0, 0, 0, GJChronology.getInstance());
            if (dt == null) {
                System.out.println("Anti optimise");
            }/*  w  w w  .j a v a  2s .c  om*/
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaGetYear() {
    int COUNT = COUNT_VERY_FAST;
    DateTime dt = new DateTime(GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "getYear");
        for (int j = 0; j < COUNT; j++) {
            int val = dt.getYear();
            if (val == 0) {
                System.out.println("Anti optimise");
            }/*from  w w w  .ja  v a2s  .c  om*/
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaGetMonth() {
    int COUNT = COUNT_VERY_FAST;
    DateTime dt = new DateTime(GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "getMonth");
        for (int j = 0; j < COUNT; j++) {
            int val = dt.getMonthOfYear();
            if (val == 0) {
                System.out.println("Anti optimise");
            }/*from www . ja v a  2  s.co  m*/
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaGetDay() {
    int COUNT = COUNT_VERY_FAST;
    DateTime dt = new DateTime(GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "getDay");
        for (int j = 0; j < COUNT; j++) {
            int val = dt.getDayOfMonth();
            if (val == 0) {
                System.out.println("Anti optimise");
            }//from w  w  w  .j  a v a2  s.  com
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaGetHour() {
    int COUNT = COUNT_VERY_FAST;
    DateTime dt = new DateTime(GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "getHour");
        for (int j = 0; j < COUNT; j++) {
            int val = dt.getHourOfDay();
            if (val == -1) {
                System.out.println("Anti optimise");
            }/* w w  w .  java2 s .  c  om*/
        }
        end(COUNT);
    }
}

From source file:org.joda.example.time.DateTimePerformance.java

License:Apache License

private void checkJodaSetYear() {
    int COUNT = COUNT_FAST;
    // Is it fair to use only MutableDateTime here? You decide.
    MutableDateTime dt = new MutableDateTime(GJChronology.getInstance());
    for (int i = 0; i < AVERAGE; i++) {
        start("Joda", "setYear");
        for (int j = 0; j < COUNT; j++) {
            dt.setYear(1972);//from  www.ja  va  2 s . co  m
            if (dt == null) {
                System.out.println("Anti optimise");
            }
        }
        end(COUNT);
    }
}