/** * Converts this object to a <code>DateMidnight</code> using the * same millis and chronology. * * @return a DateMidnight using the same millis and chronology * @deprecated DateMidnight is deprecated */ @Deprecated public DateMidnight toDateMidnight() { return new DateMidnight(getMillis(), getChronology()); }
/** * Returns a copy of this date with a different time zone, preserving the day * The returned object will have a local time of midnight in the new zone on * the same day as the original instant. * * @param newZone the new time zone, null means default * @return a copy of this instant with a different time zone */ public DateMidnight withZoneRetainFields(DateTimeZone newZone) { newZone = DateTimeUtils.getZone(newZone); DateTimeZone originalZone = DateTimeUtils.getZone(getZone()); if (newZone == originalZone) { return this; } long millis = originalZone.getMillisKeepLocal(newZone, getMillis()); return new DateMidnight(millis, getChronology().withZone(newZone)); }
/** * Returns a copy of this date with a different millisecond instant. * The returned object will have a local time of midnight. * <p> * Only the millis will change, the chronology and time zone are kept. * The returned object will be either be a new instance or <code>this</code>. * * @param newMillis the new millis, from 1970-01-01T00:00:00Z * @return a copy of this instant with different millis */ public DateMidnight withMillis(long newMillis) { Chronology chrono = getChronology(); newMillis = checkInstant(newMillis, chrono); return (newMillis == getMillis() ? this : new DateMidnight(newMillis, chrono)); }
/** * Rounds to the highest whole unit of this field on a copy of this DateMidnight. * * @return a copy of the DateMidnight with the field value changed */ public DateMidnight roundCeilingCopy() { return iInstant.withMillis(iField.roundCeiling(iInstant.getMillis())); }
/** * Rounds to the nearest whole unit of this field on a copy of this DateMidnight. * If halfway, the ceiling is favored over the floor only if it makes this field's value even. * * @return a copy of the DateMidnight with the field value changed */ public DateMidnight roundHalfEvenCopy() { return iInstant.withMillis(iField.roundHalfEven(iInstant.getMillis())); }
return 12.34; case "bound_date": return new LocalDate(2001, 8, 22).toDateMidnight(DateTimeZone.UTC).getMillis(); case "bound_time": return new LocalTime(3, 4, 5, 321).toDateTime(new DateTime(0, DateTimeZone.UTC)).getMillis(); case "bound_timestamp": return new DateTime(2001, 8, 22, 3, 4, 5, 321, DateTimeZone.UTC).getMillis(); case "bound_pattern": return utf8Slice("%el%");
new DateMidnight().withHour(..).widthMinute(..).isBefore(new DateTime())
@Deprecated public static Interval getInterval(YearMonthDay startDate, YearMonthDay endDate) { long start = startDate == null ? Long.MIN_VALUE : startDate.toDateMidnight().getMillis(); long end = endDate == null ? Long.MAX_VALUE : endDate.toDateMidnight().toDateTime().withTime(23, 59, 59, 999).getMillis(); return new Interval(start, end); }
void removeDays(int i) { DateTime first = beginningOfSeries(); DateTime midnight = first.toDateMidnight().toDateTime(); DateTime cutoff = midnight.plusDays(i); prices = new TreeMap<DateTime, BigDecimal>(prices.tailMap(cutoff)); } }
@Override public PostingRule getPostingRule() { return getServiceAgreementTemplate().findPostingRuleByEventTypeAndDate(getEventType(), getExecutionYear().getBeginDateYearMonthDay().toDateMidnight().toDateTime().plusSeconds(1)); }
@Override public DateMidnight deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // We'll accept either long (timestamp) or array: if (jp.isExpectedStartArrayToken()) { jp.nextToken(); // VALUE_NUMBER_INT int year = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int month = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int day = jp.getIntValue(); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after DateMidnight ints"); } return new DateMidnight(year, month, day); } switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: return new DateMidnight(jp.getLongValue()); case VALUE_STRING: DateTime local = parseLocal(jp); if (local == null) { return null; } return local.toDateMidnight(); } throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "expected JSON Array, Number or String"); } }
/** * Returns a copy of this date with the month of year field updated. * <p> * DateMidnight is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * month of year changed. * * @param monthOfYear the month of year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateMidnight withMonthOfYear(int monthOfYear) { return withMillis(getChronology().monthOfYear().set(getMillis(), monthOfYear)); }
/** * Returns a copy of this date with the day of month field updated. * <p> * DateMidnight is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of month changed. * * @param dayOfMonth the day of month to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateMidnight withDayOfMonth(int dayOfMonth) { return withMillis(getChronology().dayOfMonth().set(getMillis(), dayOfMonth)); }
/** * Returns a copy of this date with the day of week field updated. * <p> * DateMidnight is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of week changed. * * @param dayOfWeek the day of week to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateMidnight withDayOfWeek(int dayOfWeek) { return withMillis(getChronology().dayOfWeek().set(getMillis(), dayOfWeek)); }
/** * Returns a copy of this date minus the specified number of months. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight subtracted = dt.minusMonths(6); * DateMidnight subtracted = dt.minus(Period.months(6)); * DateMidnight subtracted = dt.withFieldAdded(DurationFieldType.months(), -6); * </pre> * * @param months the amount of months to subtract, may be negative * @return the new datetime minus the increased months * @since 1.1 */ public DateMidnight minusMonths(int months) { if (months == 0) { return this; } long instant = getChronology().months().subtract(getMillis(), months); return withMillis(instant); }
/** * Returns a copy of this date with the year field updated. * <p> * DateMidnight is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year changed. * * @param year the year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateMidnight withYear(int year) { return withMillis(getChronology().year().set(getMillis(), year)); }
/** * Returns a copy of this date plus the specified number of years. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight added = dt.plusYears(6); * DateMidnight added = dt.plus(Period.years(6)); * DateMidnight added = dt.withFieldAdded(DurationFieldType.years(), 6); * </pre> * * @param years the amount of years to add, may be negative * @return the new datetime plus the increased years * @since 1.1 */ public DateMidnight plusYears(int years) { if (years == 0) { return this; } long instant = getChronology().years().add(getMillis(), years); return withMillis(instant); }
/** * Obtains a {@code DateMidnight} set to the current system millisecond time * using <code>ISOChronology</code> in the default time zone. * The constructed object will have a local time of midnight. * * @return the current date, not null * @since 2.0 */ public static DateMidnight now() { return new DateMidnight(); }
/** * Returns a copy of this date plus the specified number of months. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight added = dt.plusMonths(6); * DateMidnight added = dt.plus(Period.months(6)); * DateMidnight added = dt.withFieldAdded(DurationFieldType.months(), 6); * </pre> * * @param months the amount of months to add, may be negative * @return the new datetime plus the increased months * @since 1.1 */ public DateMidnight plusMonths(int months) { if (months == 0) { return this; } long instant = getChronology().months().add(getMillis(), months); return withMillis(instant); }
/** * Returns a copy of this date with the year of century field updated. * <p> * DateMidnight is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year of century changed. * * @param yearOfCentury the year of century to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateMidnight withYearOfCentury(int yearOfCentury) { return withMillis(getChronology().yearOfCentury().set(getMillis(), yearOfCentury)); }