/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
MutableDateTime epoch = new MutableDateTime(); epoch.setDate(0); //Set to Epoch time DateTime now = new DateTime(); Days days = Days.daysBetween(epoch, now); Weeks weeks = Weeks.weeksBetween(epoch, now); Months months = Months.monthsBetween(epoch, now); System.out.println("Days Since Epoch: " + days.getDays()); System.out.println("Weeks Since Epoch: " + weeks.getWeeks()); System.out.println("Months Since Epoch: " + months.getMonths());
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from another instant. * The time part of this object will be unaffected. * <p> * If the input is a {@code ReadableDateTime} then it is converted to the * same time-zone as this object before using the instant millis. * * @param instant an instant to copy the date from, time part ignored * @throws IllegalArgumentException if the object is invalid */ public void setDate(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); if (instant instanceof ReadableDateTime) { ReadableDateTime rdt = (ReadableDateTime) instant; Chronology instantChrono = DateTimeUtils.getChronology(rdt.getChronology()); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(getZone(), instantMillis); } } setDate(instantMillis); }
/** * Set the date from another instant. * The time part of this object will be unaffected. * <p> * If the input is a {@code ReadableDateTime} then it is converted to the * same time-zone as this object before using the instant millis. * * @param instant an instant to copy the date from, time part ignored * @throws IllegalArgumentException if the object is invalid */ public void setDate(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); if (instant instanceof ReadableDateTime) { ReadableDateTime rdt = (ReadableDateTime) instant; Chronology instantChrono = DateTimeUtils.getChronology(rdt.getChronology()); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(getZone(), instantMillis); } } setDate(instantMillis); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from another instant. * The time part of this object will be unaffected. * * @param instant an instant to copy the date from, time part ignored * @throws IllegalArgumentException if the object is invalid */ public void setDate(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); Chronology instantChrono = DateTimeUtils.getInstantChronology(instant); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(DateTimeZone.UTC, instantMillis); } setDate(instantMillis); }
OrcParser(ParseSetup setup, Key<Job> jobKey) { super(setup, jobKey); epoch.setDate(0); // used to figure out leap seconds, years this.orcFileReader = ((OrcParser.OrcParseSetup) setup).orcFileReader; }
MutableDateTime mutable = new MutableDateTime( 1970, 1, 1, 22, 30, 0 ); mutable.setDate( 1980, 2, 3 ); mutable.setTime( 15, 20, 0, 0 ); // at this point, mutable contains 1980-2-3 15:20
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Set the date from fields. * The time part of this object will be unaffected. * * @param year the year * @param monthOfYear the month of the year * @param dayOfMonth the day of the month * @throws IllegalArgumentException if the value is invalid */ public void setDate( final int year, final int monthOfYear, final int dayOfMonth) { Chronology c = getChronology(); long instantMidnight = c.getDateTimeMillis(year, monthOfYear, dayOfMonth, 0); setDate(instantMidnight); }
/** * Helper for getting epoch {@link DateTime} object * * @return {@link DateTime} representing epoch */ public static DateTime epoch() { MutableDateTime epoch = new MutableDateTime(); epoch.setDate(0); epoch.setTime(0); return epoch.toDateTime(); }
/** * Set the date from another instant. * The time part of this object will be unaffected. * * @param instant an instant to copy the date from, time part ignored * @throws IllegalArgumentException if the object is invalid */ public void setDate(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); Chronology instantChrono = DateTimeUtils.getInstantChronology(instant); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(DateTimeZone.UTC, instantMillis); } setDate(instantMillis); }
/** * Set the date from another instant. * The time part of this object will be unaffected. * * @param instant an instant to copy the date from, time part ignored * @throws IllegalArgumentException if the object is invalid */ public void setDate(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); Chronology instantChrono = DateTimeUtils.getInstantChronology(instant); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(DateTimeZone.UTC, instantMillis); } setDate(instantMillis); }
private static int encodeDate(Date date) { MutableDateTime jodaDate = new MutableDateTime(); jodaDate.setDate(date.getYear(), date.getMonth(), date.getDayOfMonth()); return Days.daysBetween(MIN_DATE, jodaDate).getDays(); } }