本文整理汇总了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;
}
示例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;
}