Refine search
/** * Constructs a Partial with no fields or values, which can be considered * to represent any date. * <p> * This is most useful when constructing partials, for example: * <pre> * Partial p = new Partial(chrono) * .with(DateTimeFieldType.dayOfWeek(), 5) * .with(DateTimeFieldType.hourOfDay(), 12) * .with(DateTimeFieldType.minuteOfHour(), 20); * </pre> * Note that, although this is a clean way to write code, it is fairly * inefficient internally. * * @param chrono the chronology, null means ISO */ public Partial(Chronology chrono) { super(); iChronology = DateTimeUtils.getChronology(chrono).withUTC(); iTypes = new DateTimeFieldType[0]; iValues = new int[0]; }
/** * Constructs a Partial with no fields or values, which can be considered * to represent any date. * <p> * This is most useful when constructing partials, for example: * <pre> * Partial p = new Partial(chrono) * .with(DateTimeFieldType.dayOfWeek(), 5) * .with(DateTimeFieldType.hourOfDay(), 12) * .with(DateTimeFieldType.minuteOfHour(), 20); * </pre> * Note that, although this is a clean way to write code, it is fairly * inefficient internally. * * @param chrono the chronology, null means ISO */ public Partial(Chronology chrono) { super(); iChronology = DateTimeUtils.getChronology(chrono).withUTC(); iTypes = new DateTimeFieldType[0]; iValues = new int[0]; }
/** * Constructs a LocalTime from the specified millis of day using the * specified chronology. * <p> * The millisOfDay value may exceed the number of millis in one day, * but additional days will be ignored. * This method uses the UTC time zone internally. * * @param millisOfDay the number of milliseconds into a day to convert * @param chrono the chronology, null means ISO chronology */ public static LocalTime fromMillisOfDay(long millisOfDay, Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono).withUTC(); return new LocalTime(millisOfDay, chrono); }
/** * Constructs a TimeOfDay from the specified millis of day using the * specified chronology. * <p> * The millisOfDay value may exceed the number of millis in one day, * but additional days will be ignored. * This method uses the UTC time zone internally. * * @param millisOfDay the number of milliseconds into a day to convert * @param chrono the chronology, null means ISO chronology */ public static TimeOfDay fromMillisOfDay(long millisOfDay, Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono); chrono = chrono.withUTC(); return new TimeOfDay(millisOfDay, chrono); }
/** * Constructs a LocalTime from the specified millis of day using the * specified chronology. * <p> * The millisOfDay value may exceed the number of millis in one day, * but additional days will be ignored. * This method uses the UTC time zone internally. * * @param millisOfDay the number of milliseconds into a day to convert * @param chrono the chronology, null means ISO chronology */ public static LocalTime fromMillisOfDay(long millisOfDay, Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono).withUTC(); return new LocalTime(millisOfDay, chrono); }
/** * Constructs a partial extracting the partial fields from the specified * milliseconds using the chronology provided. * <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). * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in the default zone */ protected BasePartial(long instant, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology); iChronology = chronology.withUTC(); iValues = chronology.get(this, instant); }
/** * Constructs a TimeOfDay from the specified millis of day using the * specified chronology. * <p> * The millisOfDay value may exceed the number of millis in one day, * but additional days will be ignored. * This method uses the UTC time zone internally. * * @param millisOfDay the number of milliseconds into a day to convert * @param chrono the chronology, null means ISO chronology */ public static TimeOfDay fromMillisOfDay(long millisOfDay, Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono); chrono = chrono.withUTC(); return new TimeOfDay(millisOfDay, chrono); }
/** * Constructs a partial extracting the partial fields from the specified * milliseconds using the chronology provided. * <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). * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in the default zone */ protected BasePartial(long instant, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology); iChronology = chronology.withUTC(); iValues = chronology.get(this, instant); }
/** * Constructs a partial with specified time field values and chronology. * <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). * <p> * The array of values is assigned (not cloned) to the new instance. * * @param values the new set of values * @param chronology the chronology, null means ISOChronology in the default zone * @throws IllegalArgumentException if the values are invalid */ protected BasePartial(int[] values, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology); iChronology = chronology.withUTC(); chronology.validate(this, values); iValues = values; }
/** * Constructs a Partial with the specified field and value. * <p> * The constructor uses the specified chronology. * * @param type the single type to create the partial from, not null * @param value the value to store * @param chronology the chronology, null means ISO * @throws IllegalArgumentException if the type or value is invalid */ public Partial(DateTimeFieldType type, int value, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); iChronology = chronology; if (type == null) { throw new IllegalArgumentException("The field type must not be null"); } iTypes = new DateTimeFieldType[] {type}; iValues = new int[] {value}; chronology.validate(this, iValues); }
/** * Constructs an instance set to the specified date and time * using the specified chronology, whose zone is ignored. * <p> * If the chronology is null, <code>ISOChronology</code> is used. * * @param year the year, valid values defined by the chronology * @param monthOfYear the month of the year, valid values defined by the chronology * @param dayOfMonth the day of the month, valid values defined by the chronology * @param chronology the chronology, null means ISOChronology in default zone */ public LocalDate( int year, int monthOfYear, int dayOfMonth, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); long instant = chronology.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); iChronology = chronology; iLocalMillis = instant; }
/** * Constructs a partial with specified time field values and chronology. * <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). * <p> * The array of values is assigned (not cloned) to the new instance. * * @param values the new set of values * @param chronology the chronology, null means ISOChronology in the default zone * @throws IllegalArgumentException if the values are invalid */ protected BasePartial(int[] values, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology); iChronology = chronology.withUTC(); chronology.validate(this, values); iValues = values; }
/** * Constructs an instance set to the specified time * using the specified chronology, whose zone is ignored. * <p> * If the chronology is null, <code>ISOChronology</code> is used. * * @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 LocalTime( int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); long instant = chronology.getDateTimeMillis( 0L, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); iChronology = chronology; iLocalMillis = instant; }
/** * Constructs a Partial with the specified field and value. * <p> * The constructor uses the specified chronology. * * @param type the single type to create the partial from, not null * @param value the value to store * @param chronology the chronology, null means ISO * @throws IllegalArgumentException if the type or value is invalid */ public Partial(DateTimeFieldType type, int value, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); iChronology = chronology; if (type == null) { throw new IllegalArgumentException("The field type must not be null"); } iTypes = new DateTimeFieldType[] {type}; iValues = new int[] {value}; chronology.validate(this, iValues); }
/** * Constructs an instance set to the specified date and time * using the specified chronology, whose zone is ignored. * <p> * If the chronology is null, <code>ISOChronology</code> is used. * * @param year the year, valid values defined by the chronology * @param monthOfYear the month of the year, valid values defined by the chronology * @param dayOfMonth the day of the month, valid values defined by the chronology * @param chronology the chronology, null means ISOChronology in default zone */ public LocalDate( int year, int monthOfYear, int dayOfMonth, Chronology chronology) { super(); chronology = DateTimeUtils.getChronology(chronology).withUTC(); long instant = chronology.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); iChronology = chronology; iLocalMillis = instant; }
/** * Constructs a bucket, with the option of specifying the pivot year for * two-digit year parsing. * * @param instantLocal the initial millis from 1970-01-01T00:00:00, local time * @param chrono the chronology to use * @param locale the locale to use * @param pivotYear the pivot year to use when parsing two-digit years * @param defaultYear the default year to use when parsing month-day * @since 2.0 */ public DateTimeParserBucket(long instantLocal, Chronology chrono, Locale locale, Integer pivotYear, int defaultYear) { super(); chrono = DateTimeUtils.getChronology(chrono); iMillis = instantLocal; iDefaultZone = chrono.getZone(); iChrono = chrono.withUTC(); iLocale = (locale == null ? Locale.getDefault() : locale); iDefaultYear = defaultYear; iDefaultPivotYear = pivotYear; // reset iZone = iDefaultZone; iPivotYear = iDefaultPivotYear; iSavedFields = new SavedField[8]; }
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p> * 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 LocalDateTime(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); iLocalMillis = localMillis; iChronology = chronology.withUTC(); }
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p> * 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 LocalDateTime(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); iLocalMillis = localMillis; iChronology = chronology.withUTC(); }
/** * Creates a new Partial instance with the specified chronology. * This instance is immutable and unaffected by this method call. * <p> * 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 Partial * 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 Partial withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { Partial newPartial = new Partial(newChronology, iTypes, iValues); newChronology.validate(newPartial, iValues); return newPartial; } }
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p> * 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 LocalDate(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); chronology = chronology.withUTC(); iLocalMillis = chronology.dayOfMonth().roundFloor(localMillis); iChronology = chronology; }