本文整理汇总了Java中org.joda.time.chrono.GregorianChronology.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java GregorianChronology.getInstance方法的具体用法?Java GregorianChronology.getInstance怎么用?Java GregorianChronology.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.chrono.GregorianChronology
的用法示例。
在下文中一共展示了GregorianChronology.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reformatFerretToISO
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
private String reformatFerretToISO(String in) {
Chronology chrono = GregorianChronology.getInstance(DateTimeZone.UTC);
DateTimeFormatter iso = ISODateTimeFormat.dateTime().withChronology(chrono).withZone(DateTimeZone.UTC);;
DateTimeFormatter sFerretForm = DateTimeFormat.forPattern("dd-MMM-yyyy").withChronology(chrono).withZone(DateTimeZone.UTC);
DateTimeFormatter lFerretForm = DateTimeFormat.forPattern("dd-MMM-yyyy HH:mm").withChronology(chrono).withZone(DateTimeZone.UTC);
DateTime td;
try {
td = lFerretForm.parseDateTime(in).withZone(DateTimeZone.UTC).withChronology(chrono);
} catch (Exception e) {
try {
td = sFerretForm.parseDateTime(in).withZone(DateTimeZone.UTC).withChronology(chrono);
} catch (Exception e2) {
return null;
}
}
if ( td != null ) {
return iso.print(td.getMillis());
} else {
return null;
}
}
示例2: getChronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的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);
}
}
示例3: testBug2182444_ausNSW
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
public void testBug2182444_ausNSW() {
Chronology chronAusNSW = GregorianChronology.getInstance(DateTimeZone.forID("Australia/NSW"));
Chronology chronUTC = GregorianChronology.getInstance(DateTimeZone.UTC);
DateTime australiaNSWStandardInUTC = new DateTime(2008, 4, 5, 16, 0, 0, 0, chronUTC);
DateTime australiaNSWDaylightInUTC = new DateTime(2008, 4, 5, 15, 0, 0, 0, chronUTC);
assertTrue("Should be standard time", chronAusNSW.getZone().isStandardOffset(australiaNSWStandardInUTC.getMillis()));
assertFalse("Should be daylight time", chronAusNSW.getZone().isStandardOffset(australiaNSWDaylightInUTC.getMillis()));
DateTime australiaNSWStandardInAustraliaNSW = australiaNSWStandardInUTC.toDateTime(chronAusNSW);
DateTime australiaNSWDaylightInAusraliaNSW = australiaNSWDaylightInUTC.toDateTime(chronAusNSW);
assertEquals(2, australiaNSWStandardInAustraliaNSW.getHourOfDay());
assertEquals(australiaNSWStandardInAustraliaNSW.getHourOfDay(), australiaNSWDaylightInAusraliaNSW.getHourOfDay());
assertTrue(australiaNSWStandardInAustraliaNSW.getMillis() != australiaNSWDaylightInAusraliaNSW.getMillis());
assertEquals(australiaNSWStandardInAustraliaNSW, australiaNSWStandardInAustraliaNSW.withHourOfDay(2));
assertEquals(australiaNSWStandardInAustraliaNSW.getMillis() + 3, australiaNSWStandardInAustraliaNSW.withMillisOfSecond(3).getMillis());
assertEquals(australiaNSWDaylightInAusraliaNSW, australiaNSWDaylightInAusraliaNSW.withHourOfDay(2));
assertEquals(australiaNSWDaylightInAusraliaNSW.getMillis() + 3, australiaNSWDaylightInAusraliaNSW.withMillisOfSecond(3).getMillis());
}
示例4: testIsAfter
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
public void testIsAfter() {
MutableDateTime test1 = new MutableDateTime(TEST_TIME1);
MutableDateTime test1a = new MutableDateTime(TEST_TIME1);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
MutableDateTime test2 = new MutableDateTime(TEST_TIME2);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
MutableDateTime test3 = new MutableDateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
assertEquals(true, test2.isAfter(new MockInstant()));
assertEquals(false, test1.isAfter(new MockInstant()));
assertEquals(true, new MutableDateTime(TEST_TIME_NOW + 1).isAfter(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW).isAfter(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW - 1).isAfter(null));
}
示例5: difference_between_two_dates_joda
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
@Test
public void difference_between_two_dates_joda () {
DateTime sinceGraduation = new DateTime(1984, 6, 4, 0, 0, GregorianChronology.getInstance());
DateTime currentDate = new DateTime(); //current date
Days diffInDays = Days.daysBetween(sinceGraduation, currentDate);
Hours diffInHours = Hours.hoursBetween(sinceGraduation, currentDate);
Minutes diffInMinutes = Minutes.minutesBetween(sinceGraduation, currentDate);
Seconds seconds = Seconds.secondsBetween(sinceGraduation, currentDate);
logger.info(diffInDays.getDays());
logger.info(diffInHours.getHours());
logger.info(diffInMinutes.getMinutes());
logger.info(seconds.getSeconds());
assertTrue(diffInDays.getDays() >= 10697);
assertTrue(diffInHours.getHours() >= 256747);
assertTrue(diffInMinutes.getMinutes() >= 15404876);
assertTrue(seconds.getSeconds() >= 924292577);
}
示例6: RangeDataPointAggregator
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
public RangeDataPointAggregator(DataPointGroup innerDataPointGroup,
RangeSubAggregator subAggregator)
{
super(innerDataPointGroup);
m_subAggregator = subAggregator;
m_dpIterator = new ArrayList<DataPoint>().iterator();
Chronology chronology = GregorianChronology.getInstance(m_timeZone);
TimeUnit tu = m_sampling.getUnit();
switch (tu)
{
case YEARS:
m_unitField = chronology.year();
break;
case MONTHS:
m_unitField = chronology.monthOfYear();
break;
case WEEKS:
m_unitField = chronology.weekOfWeekyear();
break;
case DAYS:
m_unitField = chronology.dayOfMonth();
break;
case HOURS:
m_unitField = chronology.hourOfDay();
break;
case MINUTES:
m_unitField = chronology.minuteOfHour();
break;
case SECONDS:
m_unitField = chronology.secondOfDay();
break;
default:
m_unitField = chronology.millisOfSecond();
break;
}
}
示例7: testConstructor_invalidObject_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (Object, Chronology)
*/
public void testConstructor_invalidObject_Chronology() throws Throwable {
try {
new DateMidnight(new Object(), GregorianChronology.getInstance());
fail();
} catch (IllegalArgumentException ex) {}
}
示例8: testConstructor_badconverterObject_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (Object, Chronology)
*/
public void testConstructor_badconverterObject_Chronology() throws Throwable {
try {
ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
DateTime test = new DateTime(new Integer(0), GregorianChronology.getInstance());
assertEquals(ISOChronology.getInstance(), test.getChronology());
assertEquals(0L, test.getMillis());
} finally {
ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
}
}
示例9: testConstructor_badconverterObject_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (Object, Chronology)
*/
public void testConstructor_badconverterObject_Chronology() throws Throwable {
try {
ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
DateMidnight test = new DateMidnight(new Integer(0), GregorianChronology.getInstance());
assertEquals(ISOChronology.getInstance(), test.getChronology());
assertEquals(0L - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
} finally {
ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
}
}
示例10: testConstructor_badconverterObject_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (Object, Chronology)
*/
public void testConstructor_badconverterObject_Chronology() throws Throwable {
try {
ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
MutableDateTime test = new MutableDateTime(new Integer(0), GregorianChronology.getInstance());
assertEquals(ISOChronology.getInstance(), test.getChronology());
assertEquals(0L, test.getMillis());
} finally {
ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
}
}
示例11: testConstructor_Object_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (Object, Chronology)
*/
public void testConstructor_Object_Chronology() throws Throwable {
Date date = new Date(TEST_TIME1);
MutableDateTime test = new MutableDateTime(date, GregorianChronology.getInstance());
assertEquals(GregorianChronology.getInstance(), test.getChronology());
assertEquals(TEST_TIME1, test.getMillis());
}
示例12: GregorianCalendar
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
protected GregorianCalendar()
{
super( GregorianChronology.getInstance( DateTimeZone.getDefault() ) );
}
示例13: testConstructor_int_int_int_int_int_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (int, int, int, int, int, Chronology)
*/
public void testConstructor_int_int_int_int_int_Chronology() throws Throwable {
DateTime test = new DateTime(2002, 6, 9, 1, 0, GregorianChronology.getInstance()); // +01:00
assertEquals(GregorianChronology.getInstance(), test.getChronology());
assertEquals(TEST_TIME_NOW, test.getMillis());
}
示例14: testConstructor_long2_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (long, Chronology)
*/
public void testConstructor_long2_Chronology() throws Throwable {
DateTime test = new DateTime(TEST_TIME2, GregorianChronology.getInstance());
assertEquals(GregorianChronology.getInstance(), test.getChronology());
assertEquals(TEST_TIME2, test.getMillis());
}
示例15: testConstructor_long2_Chronology
import org.joda.time.chrono.GregorianChronology; //导入方法依赖的package包/类
/**
* Test constructor (long, Chronology)
*/
public void testConstructor_long2_Chronology() throws Throwable {
DateMidnight test = new DateMidnight(TEST_TIME2_UTC, GregorianChronology.getInstance());
assertEquals(GregorianChronology.getInstance(), test.getChronology());
assertEquals(TEST_TIME2_LONDON, test.getMillis());
}