当前位置: 首页>>代码示例>>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;未经允许,请勿转载。