本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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();
}
示例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"));
}
示例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);
}
}
}
示例11: Iso8601Calendar
import org.joda.time.chrono.ISOChronology; //导入方法依赖的package包/类
protected Iso8601Calendar()
{
super( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
}
示例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();
}
示例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));
}
示例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));
}
示例15: setUp
import org.joda.time.chrono.ISOChronology; //导入方法依赖的package包/类
protected void setUp() throws Exception {
JULIAN = JulianChronology.getInstance();
ISO = ISOChronology.getInstance();
}