@Override public DateTimeFieldType[] getDateTimeFields() { return new DateTimeFieldType[] { DateTimeFieldType.millisOfSecond(), DateTimeFieldType.millisOfDay() }; } private static final long serialVersionUID = 1;
/** * Instructs the printer to emit a numeric millisOfSecond field. * <p> * This method will append a field that prints a three digit value. * During parsing the value that is parsed is assumed to be three digits. * If less than three digits are present then they will be counted as the * smallest parts of the millisecond. This is probably not what you want * if you are using the field as a fraction. Instead, a fractional * millisecond should be produced using {@link #appendFractionOfSecond}. * * @param minDigits minimum number of digits to print * @return this DateTimeFormatterBuilder, for chaining */ public DateTimeFormatterBuilder appendMillisOfSecond(int minDigits) { return appendDecimal(DateTimeFieldType.millisOfSecond(), minDigits, 3); }
/** * Instructs the printer to emit a numeric millisOfSecond field. * <p> * This method will append a field that prints a three digit value. * During parsing the value that is parsed is assumed to be three digits. * If less than three digits are present then they will be counted as the * smallest parts of the millisecond. This is probably not what you want * if you are using the field as a fraction. Instead, a fractional * millisecond should be produced using {@link #appendFractionOfSecond}. * * @param minDigits minimum number of digits to print * @return this DateTimeFormatterBuilder, for chaining */ public DateTimeFormatterBuilder appendMillisOfSecond(int minDigits) { return appendDecimal(DateTimeFieldType.millisOfSecond(), minDigits, 3); }
protected void appendFractionOfSecond(int minDigits, int maxDigits) { builder.appendFractionOfSecond(minDigits, maxDigits); appendNumericField(DateTimeFieldType.millisOfSecond(), minDigits, maxDigits); }
/** * Get the millis of second field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField millisOfSecond() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.millisOfSecond(), millis()); }
/** * Get the millis of second field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField millisOfSecond() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.millisOfSecond(), millis()); }
DateTimeFieldType.millisOfSecond(), MillisDurationField.INSTANCE, field.getDurationField());
DateTimeFieldType.millisOfSecond(), MillisDurationField.INSTANCE, field.getDurationField());
boolean minute = fields.remove(DateTimeFieldType.minuteOfHour()); boolean second = fields.remove(DateTimeFieldType.secondOfMinute()); boolean milli = fields.remove(DateTimeFieldType.millisOfSecond()); if (!hour && !minute && !second && !milli) { return;
boolean minute = fields.remove(DateTimeFieldType.minuteOfHour()); boolean second = fields.remove(DateTimeFieldType.secondOfMinute()); boolean milli = fields.remove(DateTimeFieldType.millisOfSecond()); if (!hour && !minute && !second && !milli) { return;
@Override public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23); FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); long millisOfDay = hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; return getDateTimeMillis0(year, monthOfYear, dayOfMonth, (int) millisOfDay); }
private void initBase() { if (hour >= 0) { if (hour < 24) { base = JodaTimeUtils.setField(base, DateTimeFieldType.hourOfDay(), hour); } else { base = JodaTimeUtils.setField(base, DateTimeFieldType.clockhourOfDay(), hour); } } if (minute >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.minuteOfHour(), minute); if (second >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.secondOfMinute(), second); if (millis >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.millisOfSecond(), millis); if (halfday >= 0) { base = JodaTimeUtils.setField(base, DateTimeFieldType.halfdayOfDay(), halfday); } } private static final long serialVersionUID = 1;
@Override public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23); FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); long millisOfDay = hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; return getDateTimeMillis0(year, monthOfYear, dayOfMonth, (int) millisOfDay); }
public static Instant getInstant(Partial p, ZoneId timezone) { if (p == null) return null; int year = p.isSupported(DateTimeFieldType.year())? p.get(DateTimeFieldType.year()):0; if (!p.isSupported(DateTimeFieldType.year())) { if (p.isSupported(DateTimeFieldType.centuryOfEra())) { year += 100*p.get(DateTimeFieldType.centuryOfEra()); } if (p.isSupported(DateTimeFieldType.yearOfCentury())) { year += p.get(DateTimeFieldType.yearOfCentury()); } else if (p.isSupported(DecadeOfCentury)) { year += 10*p.get(DecadeOfCentury); } } int moy = p.isSupported(DateTimeFieldType.monthOfYear())? p.get(DateTimeFieldType.monthOfYear()):1; if (!p.isSupported(DateTimeFieldType.monthOfYear())) { if (p.isSupported(QuarterOfYear)) { moy += 3*(p.get(QuarterOfYear)-1); } } int dom = p.isSupported(DateTimeFieldType.dayOfMonth())? p.get(DateTimeFieldType.dayOfMonth()):1; int hod = p.isSupported(DateTimeFieldType.hourOfDay())? p.get(DateTimeFieldType.hourOfDay()):0; int moh = p.isSupported(DateTimeFieldType.minuteOfHour())? p.get(DateTimeFieldType.minuteOfHour()):0; int som = p.isSupported(DateTimeFieldType.secondOfMinute())? p.get(DateTimeFieldType.secondOfMinute()):0; int msos = p.isSupported(DateTimeFieldType.millisOfSecond())? p.get(DateTimeFieldType.millisOfSecond()):0; return new DateTime(year, moy, dom, hod, moh, som, msos, fromTimezone(timezone)).toInstant(); }
/** * Instructs the printer to emit a numeric millisOfSecond field. * <p> * This method will append a field that prints a three digit value. * During parsing the value that is parsed is assumed to be three digits. * If less than three digits are present then they will be counted as the * smallest parts of the millisecond. This is probably not what you want * if you are using the field as a fraction. Instead, a fractional * millisecond should be produced using {@link #appendFractionOfSecond}. * * @param minDigits minimum number of digits to print * @return this DateTimeFormatterBuilder, for chaining */ public DateTimeFormatterBuilder appendMillisOfSecond(int minDigits) { return appendDecimal(DateTimeFieldType.millisOfSecond(), minDigits, 3); }
/** * Get the millis of second field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField millisOfSecond() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.millisOfSecond(), millis()); }
builder.appendLiteral(PAD_FIELD_UNKNOWN2); if (JodaTimeUtils.hasField(base, DateTimeFieldType.millisOfSecond())) { builder.appendLiteral("."); builder.appendMillisOfSecond(3);
(DateTimeFieldType.millisOfSecond(), cMillisField, cSecondsField);
(DateTimeFieldType.millisOfSecond(), cMillisField, cSecondsField);
private long getDateTimeMillis(ReadablePartial partial) { int year = partial.get(DateTimeFieldType.year()); int monthOfYear = partial.get(DateTimeFieldType.monthOfYear()); int dayOfMonth = partial.get(DateTimeFieldType.dayOfMonth()); int hourOfDay = partial.get(DateTimeFieldType.hourOfDay()); int minuteOfHour = partial.get(DateTimeFieldType.minuteOfHour()); int secondOfMinute = partial.get(DateTimeFieldType.secondOfMinute()); int millisOfSecond = partial.get(DateTimeFieldType.millisOfSecond()); return partial.getChronology().getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } }