當前位置: 首頁>>代碼示例>>Java>>正文


Java ISOChronology.getInstance方法代碼示例

本文整理匯總了Java中org.joda.time.chrono.ISOChronology.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java ISOChronology.getInstance方法的具體用法?Java ISOChronology.getInstance怎麽用?Java ISOChronology.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.chrono.ISOChronology的用法示例。


在下文中一共展示了ISOChronology.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getChronology

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:29,代碼來源:CalendarConverter.java

示例2: AgeCalculator

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
public AgeCalculator() {
    super();

    iChronology = ISOChronology.getInstance();
    iBirthdateStr = "1970-01-01T00:00:00";

    setTitle("Age Calculator");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    addMainArea(getContentPane());
    addNotify();
    Dimension size = getPreferredSize();
    setSize(size);
    Dimension screenSize = getToolkit().getScreenSize();
    setLocation(screenSize.width / 2 - size.width / 2,
                screenSize.height / 2 - size.height / 2);

    iTimer = new Timer(500, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateResults();
        }
    });

    iTimer.setInitialDelay(0);
    iTimer.start();
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:26,代碼來源:AgeCalculator.java

示例3: weeksInYear

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
@Override
public int weeksInYear( int year )
{
    DateTime dateTime = new DateTime( year, 1, 1, 0, 0,
        ISOChronology.getInstance( DateTimeZone.getDefault() ) );
    return dateTime.weekOfWeekyear().getMaximumValue();
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:8,代碼來源:PersianCalendar.java

示例4: getInstantChronology

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
/**
 * Gets the chronology from the specified instant object handling null.
 * <p>
 * If the instant object is <code>null</code>, or the instant's chronology is
 * <code>null</code>, {@link ISOChronology#getInstance()} will be returned.
 * Otherwise, the chronology from the object is returned.
 * 
 * @param instant  the instant to examine, null means ISO in the default zone
 * @return the chronology, never null
 */
public static final Chronology getInstantChronology(ReadableInstant instant) {
    if (instant == null) {
        return ISOChronology.getInstance();
    }
    Chronology chrono = instant.getChronology();
    if (chrono == null) {
        return ISOChronology.getInstance();
    }
    return chrono;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:21,代碼來源:DateTimeUtils.java

示例5: BaseInterval

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
/**
 * Constructs an interval from a start and end instant.
 * 
 * @param start  start of this interval, null means now
 * @param end  end of this interval, null means now
 * @throws IllegalArgumentException if the end is before the start
 */
protected BaseInterval(ReadableInstant start, ReadableInstant end) {
    super();
    if (start == null && end == null) {
        iStartMillis = iEndMillis = DateTimeUtils.currentTimeMillis();
        iChronology = ISOChronology.getInstance();
    } else {
        iChronology = DateTimeUtils.getInstantChronology(start);
        iStartMillis = DateTimeUtils.getInstantMillis(start);
        iEndMillis = DateTimeUtils.getInstantMillis(end);
        checkInterval(iStartMillis, iEndMillis);
    }
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:20,代碼來源:BaseInterval.java

示例6: getChronology

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
/**
 * Gets the chronology, which is taken from the ReadableInstant.
 * If the chronology on the instant is null, the ISOChronology in the
 * specified time zone is used.
 * If the chronology on the instant is not in the specified zone, it is
 * adapted.
 * 
 * @param object  the ReadableInstant to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    Chronology chrono = ((ReadableInstant) object).getChronology();
    if (chrono == null) {
        return ISOChronology.getInstance(zone);
    }
    DateTimeZone chronoZone = chrono.getZone();
    if (chronoZone != zone) {
        chrono = chrono.withZone(zone);
        if (chrono == null) {
            return ISOChronology.getInstance(zone);
        }
    }
    return chrono;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:26,代碼來源:ReadableInstantConverter.java

示例7: testDateMidnight

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void testDateMidnight() {
    DateMidnight test = new DateMidnight(2010, 6, 30, ISOChronology.getInstance(ZONE));
    String str = StringConvert.INSTANCE.convertToString(test);
    assertEquals("2010-06-30T00:00:00.000+02:00", str);
    assertEquals(test, StringConvert.INSTANCE.convertFromString(DateMidnight.class, str));
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:8,代碼來源:TestStringConvert.java

示例8: setUp

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
    originalDateTimeZone = DateTimeZone.getDefault();
    originalTimeZone = TimeZone.getDefault();
    originalLocale = Locale.getDefault();
    DateTimeZone.setDefault(DateTimeZone.forID("Europe/London"));
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Locale.setDefault(Locale.UK);
    
    ISO = ISOChronology.getInstance();
    JULIAN = JulianChronology.getInstance();
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:13,代碼來源:TestNullConverter.java

示例9: testParse_noFormatter

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
public void testParse_noFormatter() throws Throwable {
    DateTime start = new DateTime(2010, 6, 30, 12, 30, ISOChronology.getInstance(PARIS));
    DateTime end = new DateTime(2010, 7, 1, 14, 30, ISOChronology.getInstance(PARIS));
    assertEquals(new MutableInterval(start, end), MutableInterval.parse("2010-06-30T12:30/2010-07-01T14:30"));
    assertEquals(new MutableInterval(start, end), MutableInterval.parse("2010-06-30T12:30/P1DT2H"));
    assertEquals(new MutableInterval(start, end), MutableInterval.parse("P1DT2H/2010-07-01T14:30"));
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:8,代碼來源:TestMutableInterval_Constructors.java

示例10: testMonthNames_monthEnd

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
public void testMonthNames_monthEnd() {
    DateTimeFormatter printer = DateTimeFormat.forPattern("MMMM");
    for (int i=0; i<ZONES.length; i++) {
        Chronology chrono = ISOChronology.getInstance(ZONES[i]);
        for (int month=1; month<=12; month++) {
            DateTime dt = new DateTime(2004, month, 1, 23, 20, 30, 40, chrono);
            int lastDay = chrono.dayOfMonth().getMaximumValue(dt.getMillis());
            dt = new DateTime(2004, month, lastDay, 23, 20, 30, 40, chrono);
            String monthText = printer.print(dt);
            assertEquals(MONTHS[month], monthText);
        }
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:14,代碼來源:TestTextFields.java

示例11: Iso8601Calendar

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
protected Iso8601Calendar()
{
    super( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:5,代碼來源:Iso8601Calendar.java

示例12: weeksInYear

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
@Override
public int weeksInYear( int year )
{
    DateTime dateTime = new DateTime( year, 1, 1, 0, 0, ISOChronology.getInstance( DateTimeZone.getDefault() ) );
    return dateTime.weekOfWeekyear().getMaximumValue();
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:7,代碼來源:NepaliCalendar.java

示例13: testFormatDateTimeOffsetyyyyMMddHHmmss

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
@Test
public void testFormatDateTimeOffsetyyyyMMddHHmmss() {
  Chronology c = ISOChronology.getInstance(DateTimeZone.forOffsetHours(1));
  DateTime dt = new DateTime(2010, 12, 20, 17, 34, 5, 0, c);
  Assert.assertEquals("2010-12-20T17:34:05+01:00", InternalUtil.formatDateTimeOffsetForXml(dt));
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:7,代碼來源:DateTimeFormatTest.java

示例14: testFormatDateTimeOffsetyyyyMMddHHmmssfffffff

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
@Test
public void testFormatDateTimeOffsetyyyyMMddHHmmssfffffff() {
  Chronology c = ISOChronology.getInstance(DateTimeZone.forOffsetHours(1));
  DateTime dt = new DateTime(2010, 12, 20, 17, 34, 5, 123, c);
  Assert.assertEquals("2010-12-20T17:34:05.123+01:00", InternalUtil.formatDateTimeOffsetForXml(dt));
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:7,代碼來源:DateTimeFormatTest.java

示例15: setUp

import org.joda.time.chrono.ISOChronology; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:5,代碼來源:TestReadableInstantConverter.java


注:本文中的org.joda.time.chrono.ISOChronology.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。