List of usage examples for org.joda.time DateTimeUtils getChronology
public static final Chronology getChronology(Chronology chrono)
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
/** * Constructs an instance set to the specified date and time * using the specified chronology, whose zone is ignored. * <p/>// w w w . j a va 2 s .co m * If the chronology is null, <code>ISOChronology</code> is used. * * @param dayOfWeek the day of the month, valid values defined by the chronology * @param hourOfDay the hour of the day, valid values defined by the chronology * @param minuteOfHour the minute of the hour, valid values defined by the chronology * @param secondOfMinute the second of the minute, valid values defined by the chronology * @param millisOfSecond the millisecond of the second, valid values defined by the chronology * @param chronology the chronology, null means ISOChronology in default zone */ public PeriodicalTimeFrame(int dayOfWeek, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); // First of January 1971 was a Monday = UTC week day 1 long instant = chronology.getDateTimeMillis(1, 1, dayOfWeek, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); iChronology = chronology; iLocalMillis = instant; }
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p/>//w w w . ja v a 2 s .c o m * If the chronology is null, ISO chronology in the default zone is used. * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public PeriodicalTimeFrame(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); iLocalMillis = localMillis; iChronology = chronology.withUTC(); }
From source file:net.sourceforge.fenixedu.util.HourMinuteSecond.java
License:Open Source License
/** * Constructs a HourMinuteSecond from an Object that represents a time, * using the specified chronology.//from w ww . ja va 2 s . c om * <p> * The recognised object types are defined in {@link org.joda.time.convert.ConverterManager ConverterManager} and include * ReadableInstant, String, Calendar and Date. * <p> * The constructor uses the time zone of the chronology specified. Once the constructor is complete, all further calculations * are performed without reference to a timezone (by switching to UTC). The specified chronology overrides that of the object. * * @param instant * the datetime object, null means now * @param chronology * the chronology, null means ISO default * @throws IllegalArgumentException * if the instant is invalid */ public HourMinuteSecond(Object instant, Chronology chronology) { super(instant, DateTimeUtils.getChronology(chronology)); }
From source file:net.sourceforge.fenixedu.util.HourMinuteSecond.java
License:Open Source License
/** * Creates a new HourMinuteSecond instance with the specified chronology. * This instance is immutable and unaffected by this method call. * <p>//ww w . j a v a 2s. com * This method retains the values of the fields, thus the result will typically refer to a different instant. * <p> * The time zone of the specified chronology is ignored, as HourMinuteSecond operates without a time zone. * * @param newChronology * the new chronology, null means ISO * @return a copy of this datetime with a different chronology * @throws IllegalArgumentException * if the values are invalid for the new chronology */ public HourMinuteSecond withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { HourMinuteSecond newHourMinuteSecond = new HourMinuteSecond(this, newChronology); newChronology.validate(newHourMinuteSecond, getValues()); return newHourMinuteSecond; } }
From source file:org.jsr166e.BaseDateTime.java
License:Apache License
/** * Checks the specified chronology before storing it, potentially altering it. * This method must not access any instance variables. * <p/>//from w w w . j ava2 s . com * This implementation converts nulls to ISOChronology in the default zone. * * @param chronology the chronology to use, may be null * @return the chronology to store in this datetime, not null */ protected Chronology checkChronology(Chronology chronology) { return DateTimeUtils.getChronology(chronology); }
From source file:org.renjin.primitives.time.Time.java
License:Open Source License
private static DateTime parseIgnoreTrailingCharacters(DateTimeFormatter formatter, String text) { // this is a modified version of DateTimeFormatter.parseDateTime() that does not // throw an exception on trailing characters Chronology chronology = DateTimeUtils.getChronology(null); DateTimeParser parser = formatter.getParser(); Locale locale = null;//from ww w .j av a 2s . c o m Integer pivotYear = null; int defaultYear = 2000; DateTimeZone timeZone = null; DateTimeParserBucket bucket = new DateTimeParserBucket(0, chronology, locale, pivotYear, defaultYear); int newPos = parser.parseInto(bucket, text, 0); if (newPos >= 0) { long millis = bucket.computeMillis(true, text); if (formatter.isOffsetParsed() && bucket.getOffsetInteger() != null) { int parsedOffset = bucket.getOffsetInteger(); DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset); chronology = chronology.withZone(parsedZone); } else if (bucket.getZone() != null) { chronology = chronology.withZone(bucket.getZone()); } DateTime dt = new DateTime(millis, chronology); if (timeZone != null) { dt = dt.withZone(timeZone); } return dt; } throw new IllegalArgumentException(); }