Java Code Examples for org.joda.time.chrono.ISOChronology#getInstance()
The following examples show how to use
org.joda.time.chrono.ISOChronology#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalendarConverter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example 2
Source File: TestPeriod_Constructors.java From astor with GNU General Public License v2.0 | 6 votes |
public void testConstructor_long_PeriodType_Chronology1() throws Throwable { long length = 4 * DateTimeConstants.MILLIS_PER_DAY + 5 * DateTimeConstants.MILLIS_PER_HOUR + 6 * DateTimeConstants.MILLIS_PER_MINUTE + 7 * DateTimeConstants.MILLIS_PER_SECOND + 8; Period test = new Period(length, PeriodType.time().withMillisRemoved(), ISOChronology.getInstance()); assertEquals(PeriodType.time().withMillisRemoved(), test.getPeriodType()); assertEquals(0, test.getYears()); assertEquals(0, test.getMonths()); assertEquals(0, test.getWeeks()); assertEquals(0, test.getDays()); assertEquals((4 * 24) + 5, test.getHours()); assertEquals(6, test.getMinutes()); assertEquals(7, test.getSeconds()); assertEquals(0, test.getMillis()); }
Example 3
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
protected void setUp() throws Exception { zone = DateTimeZone.getDefault(); locale = Locale.getDefault(); DateTimeZone.setDefault(LONDON); Locale.setDefault(Locale.UK); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); }
Example 4
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 5
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 6
Source File: TestReadableDurationConverter.java From astor with GNU General Public License v2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); zone = DateTimeZone.getDefault(); DateTimeZone.setDefault(PARIS); }
Example 7
Source File: ReadableInstantConverter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 8
Source File: PersianCalendar.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public int weeksInYear( int year ) { DateTime dateTime = new DateTime( year, 1, 1, 0, 0, ISOChronology.getInstance( DateTimeZone.getDefault() ) ); return dateTime.weekOfWeekyear().getMaximumValue(); }
Example 9
Source File: TestMutableInterval_Basics.java From astor with GNU General Public License v2.0 | 4 votes |
public Chronology getChronology() { return ISOChronology.getInstance(); }
Example 10
Source File: TestInterval_Basics.java From astor with GNU General Public License v2.0 | 4 votes |
public Chronology getChronology() { return ISOChronology.getInstance(); }
Example 11
Source File: TestReadablePeriodConverter.java From astor with GNU General Public License v2.0 | 4 votes |
protected void setUp() throws Exception { JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); }
Example 12
Source File: TestReadablePeriodConverter.java From astor with GNU General Public License v2.0 | 4 votes |
protected void setUp() throws Exception { JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); }
Example 13
Source File: TestMonthDay_Basics.java From astor with GNU General Public License v2.0 | 4 votes |
public void testPlusMonths_int_endOfMonthAdjust() { MonthDay test = new MonthDay(3, 31, ISOChronology.getInstanceUTC()); MonthDay result = test.plusMonths(1); MonthDay expected = new MonthDay(4, 30, ISOChronology.getInstance()); assertEquals(expected, result); }
Example 14
Source File: TestMonthDay_Basics.java From astor with GNU General Public License v2.0 | 4 votes |
public void testMinusDays_int_fromLeap() { MonthDay test = new MonthDay(2, 29, ISOChronology.getInstanceUTC()); MonthDay result = test.minusDays(1); MonthDay expected = new MonthDay(2, 28, ISOChronology.getInstance()); assertEquals(expected, result); }
Example 15
Source File: BaseDateTime.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z * using <code>ISOChronology</code> in the default time zone. * * @param instant the milliseconds from 1970-01-01T00:00:00Z */ public BaseDateTime(long instant) { this(instant, ISOChronology.getInstance()); }
Example 16
Source File: Time_12_LocalDateTime_t.java From coming with MIT License | 2 votes |
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using ISO chronology in the default zone. * <p> * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z */ public LocalDateTime(long instant) { this(instant, ISOChronology.getInstance()); }
Example 17
Source File: YearMonthDay.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Constructs a YearMonthDay with the current date, using ISOChronology in * the specified zone to extract the fields. * <p> * The constructor uses the specified time zone to obtain the current date. * Once the constructor is complete, all further calculations * are performed without reference to a timezone (by switching to UTC). * * @param zone the zone to use, null means default zone * @since 1.1 */ public YearMonthDay(DateTimeZone zone) { super(ISOChronology.getInstance(zone)); }
Example 18
Source File: LocalTime.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using ISO chronology in the default zone. * <p> * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z */ public LocalTime(long instant) { this(instant, ISOChronology.getInstance()); }
Example 19
Source File: TimeOfDay.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Constructs a TimeOfDay with the current time, using ISOChronology in * the specified zone to extract the fields. * <p> * The constructor uses the specified time zone to obtain the current time. * Once the constructor is complete, all further calculations * are performed without reference to a timezone (by switching to UTC). * * @param zone the zone to use, null means default zone * @since 1.1 */ public TimeOfDay(DateTimeZone zone) { super(ISOChronology.getInstance(zone)); }
Example 20
Source File: Time_12_LocalDateTime_s.java From coming with MIT License | 2 votes |
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using ISO chronology in the default zone. * <p> * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z */ public LocalDateTime(long instant) { this(instant, ISOChronology.getInstance()); }