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


Java ReadableInstant.toInstant方法代碼示例

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


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

示例1: getInstance

import org.joda.time.ReadableInstant; //導入方法依賴的package包/類
/**
 * Factory method returns instances of the GJ cutover chronology. Any
 * cutover date may be specified.
 *
 * @param zone  the time zone to use, null is default
 * @param gregorianCutover  the cutover to use, null means default
 * @param minDaysInFirstWeek  minimum number of days in first week of the year; default is 4
 */
public static synchronized GJChronology getInstance(
        DateTimeZone zone,
        ReadableInstant gregorianCutover,
        int minDaysInFirstWeek) {
    
    zone = DateTimeUtils.getZone(zone);
    Instant cutoverInstant;
    if (gregorianCutover == null) {
        cutoverInstant = DEFAULT_CUTOVER;
    } else {
        cutoverInstant = gregorianCutover.toInstant();
    }

    GJChronology chrono;

    ArrayList<GJChronology> chronos = cCache.get(zone);
    if (chronos == null) {
        chronos = new ArrayList<GJChronology>(2);
        cCache.put(zone, chronos);
    } else {
        for (int i=chronos.size(); --i>=0; ) {
            chrono = chronos.get(i);
            if (minDaysInFirstWeek == chrono.getMinimumDaysInFirstWeek() &&
                cutoverInstant.equals(chrono.getGregorianCutover())) {
                
                return chrono;
            }
        }
    }

    if (zone == DateTimeZone.UTC) {
        chrono = new GJChronology
            (JulianChronology.getInstance(zone, minDaysInFirstWeek),
             GregorianChronology.getInstance(zone, minDaysInFirstWeek),
             cutoverInstant);
    } else {
        chrono = getInstance(DateTimeZone.UTC, cutoverInstant, minDaysInFirstWeek);
        chrono = new GJChronology
            (ZonedChronology.getInstance(chrono, zone),
             chrono.iJulianChronology,
             chrono.iGregorianChronology,
             chrono.iCutoverInstant);
    }

    chronos.add(chrono);

    return chrono;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:57,代碼來源:GJChronology.java

示例2: getInstance

import org.joda.time.ReadableInstant; //導入方法依賴的package包/類
/**
 * Factory method returns instances of the GJ cutover chronology. Any
 * cutover date may be specified.
 *
 * @param zone  the time zone to use, null is default
 * @param gregorianCutover  the cutover to use, null means default
 * @param minDaysInFirstWeek  minimum number of days in first week of the year; default is 4
 */
public static synchronized GJChronology getInstance(
        DateTimeZone zone,
        ReadableInstant gregorianCutover,
        int minDaysInFirstWeek) {
    
    zone = DateTimeUtils.getZone(zone);
    Instant cutoverInstant;
    if (gregorianCutover == null) {
        cutoverInstant = DEFAULT_CUTOVER;
    } else {
        cutoverInstant = gregorianCutover.toInstant();
        LocalDate cutoverDate = new LocalDate(cutoverInstant.getMillis(), GregorianChronology.getInstance(zone));
        if (cutoverDate.getYear() <= 0) {
            throw new IllegalArgumentException("Cutover too early. Must be on or after 0001-01-01.");
        }
    }

    GJChronology chrono;
    synchronized (cCache) {
        ArrayList<GJChronology> chronos = cCache.get(zone);
        if (chronos == null) {
            chronos = new ArrayList<GJChronology>(2);
            cCache.put(zone, chronos);
        } else {
            for (int i = chronos.size(); --i >= 0;) {
                chrono = chronos.get(i);
                if (minDaysInFirstWeek == chrono.getMinimumDaysInFirstWeek() &&
                    cutoverInstant.equals(chrono.getGregorianCutover())) {
                    
                    return chrono;
                }
            }
        }
        if (zone == DateTimeZone.UTC) {
            chrono = new GJChronology
                (JulianChronology.getInstance(zone, minDaysInFirstWeek),
                 GregorianChronology.getInstance(zone, minDaysInFirstWeek),
                 cutoverInstant);
        } else {
            chrono = getInstance(DateTimeZone.UTC, cutoverInstant, minDaysInFirstWeek);
            chrono = new GJChronology
                (ZonedChronology.getInstance(chrono, zone),
                 chrono.iJulianChronology,
                 chrono.iGregorianChronology,
                 chrono.iCutoverInstant);
        }
        chronos.add(chrono);
    }
    return chrono;
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:59,代碼來源:GJChronology.java


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