/** * Returns a copy of this datetime with a different time zone, preserving the * millisecond instant. * <p> * This method is useful for finding the local time in another timezone. * For example, if this instant holds 12:30 in Europe/London, the result * from this method with Europe/Paris would be 13:30. * <p> * The returned object will be a new instance of the same implementation type. * This method changes the time zone, and does not change the * millisecond instant, with the effect that the field values usually change. * The returned object will be either be a new instance or <code>this</code>. * * @param newZone the new time zone * @return a copy of this datetime with a different time zone * @see #withZoneRetainFields */ public DateTime withZone(DateTimeZone newZone) { return withChronology(getChronology().withZone(newZone)); }
/** * Returns a copy of this datetime with a different time zone, preserving the * millisecond instant. * <p> * This method is useful for finding the local time in another timezone. * For example, if this instant holds 12:30 in Europe/London, the result * from this method with Europe/Paris would be 13:30. * <p> * The returned object will be a new instance of the same implementation type. * This method changes the time zone, and does not change the * millisecond instant, with the effect that the field values usually change. * The returned object will be either be a new instance or <code>this</code>. * * @param newZone the new time zone * @return a copy of this datetime with a different time zone * @see #withZoneRetainFields */ public DateTime withZone(DateTimeZone newZone) { return withChronology(getChronology().withZone(newZone)); }
/** * Returns a copy of this datetime with a different time zone, preserving the * millisecond instant. * <p> * This method is useful for finding the local time in another timezone. * For example, if this instant holds 12:30 in Europe/London, the result * from this method with Europe/Paris would be 13:30. * <p> * The returned object will be a new instance of the same implementation type. * This method changes the time zone, and does not change the * millisecond instant, with the effect that the field values usually change. * The returned object will be either be a new instance or <code>this</code>. * * @param newZone the new time zone * @return a copy of this datetime with a different time zone * @see #withZoneRetainFields */ public DateTime withZone(DateTimeZone newZone) { return withChronology(getChronology().withZone(newZone)); }
DateTime dtISO = new DateTime(2014, 1, 9, 0, 0, 0, 0); DateTimeZone tzSAUDI_ARABIA = DateTimeZone.forID("Asia/Riyadh"); DateTime dtIslamic = dtISO.withChronology( IslamicChronology.getInstance( tzSAUDI_ARABIA, IslamicChronology.LEAP_YEAR_15_BASED)); System.out.println(dtIslamic);
@Override public DateTimeUnit isoStartOfYear( int year ) { DateTime dateTime = new DateTime( year, 1, 1, 11, 0, chronology ).withChronology( ISOChronology.getInstance() ); return DateTimeUnit.fromJodaDateTime( dateTime ); } }
/** {@inheritDoc} */ protected void processElementContent(XMLObject xmlObject, String elementContent) { XSDateTime xsDateTime = (XSDateTime) xmlObject; xsDateTime.setValue(new DateTime(elementContent).withChronology(ISOChronology.getInstanceUTC())); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject xmlObject, String elementContent) { XSDateTime xsDateTime = (XSDateTime) xmlObject; xsDateTime.setValue(new DateTime(elementContent).withChronology(ISOChronology.getInstanceUTC())); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject xmlObject, String elementContent) { XSDateTime xsDateTime = (XSDateTime) xmlObject; xsDateTime.setValue(new DateTime(elementContent).withChronology(ISOChronology.getInstanceUTC())); }
/** {@inheritDoc} */ public void setValue(String newValue) { dateTimeValue = new DateTime(newValue).withChronology(ISOChronology.getInstanceUTC()); stringValue = prepareForAssignment(stringValue, newValue); }
/** {@inheritDoc} */ public void setValue(String newValue) { dateTimeValue = new DateTime(newValue).withChronology(ISOChronology.getInstanceUTC()); stringValue = prepareForAssignment(stringValue, newValue); }
/** {@inheritDoc} */ protected void processElementContent(XMLObject xmlObject, String elementContent) { XSDateTime xsDateTime = (XSDateTime) xmlObject; xsDateTime.setValue(new DateTime(elementContent).withChronology(ISOChronology.getInstanceUTC())); }
private RubyDate newStart(ThreadContext context, final long start) { DateTime dt = this.dt.withChronology(getChronology(context, start, off)); return newInstance(context, dt, off, start, subMillisNum, subMillisDen); }
public static CalendarDate withDoy(Calendar cal, int year, int doy, int hourOfDay, int minuteOfHour, int secondOfMinute) { Chronology base = Calendar.getChronology(cal); /* if (base == null) base = ISOChronology.getInstanceUTC(); // already in UTC else base = ZonedChronology.getInstance( base, DateTimeZone.UTC); // otherwise wrap it to be in UTC */ DateTime dt = new DateTime(year, 1, 1, hourOfDay, minuteOfHour, secondOfMinute, base); dt = dt.withZone(DateTimeZone.UTC); dt = dt.withDayOfYear(doy); if (!Calendar.isDefaultChronology(cal)) dt = dt.withChronology(Calendar.getChronology(cal)); return new CalendarDate(cal, dt); }
@Override public int isoWeekday( DateTimeUnit dateTimeUnit ) { DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology ); dateTime = dateTime.withChronology( ISOChronology.getInstance( DateTimeZone.getDefault() ) ); return dateTime.getDayOfWeek(); }
public static CalendarDate withDoy(Calendar cal, int year, int doy, int hourOfDay, int minuteOfHour, int secondOfMinute) { Chronology base = Calendar.getChronology(cal); /* if (base == null) base = ISOChronology.getInstanceUTC(); // already in UTC else base = ZonedChronology.getInstance( base, DateTimeZone.UTC); // otherwise wrap it to be in UTC */ DateTime dt = new DateTime(year, 1, 1, hourOfDay, minuteOfHour, secondOfMinute, base); dt = dt.withZone(DateTimeZone.UTC); dt = dt.withDayOfYear(doy); if (!Calendar.isDefaultChronology(cal)) dt = dt.withChronology(Calendar.getChronology(cal)); return new CalendarDate(cal, dt); }
public static CalendarDate withDoy(Calendar cal, int year, int doy, int hourOfDay, int minuteOfHour, int secondOfMinute) { Chronology base = Calendar.getChronology(cal); /* if (base == null) base = ISOChronology.getInstanceUTC(); // already in UTC else base = ZonedChronology.getInstance( base, DateTimeZone.UTC); // otherwise wrap it to be in UTC */ DateTime dt = new DateTime(year, 1, 1, hourOfDay, minuteOfHour, secondOfMinute, base); dt = dt.withZone(DateTimeZone.UTC); dt = dt.withDayOfYear(doy); if (!Calendar.isDefaultChronology(cal)) dt = dt.withChronology(Calendar.getChronology(cal)); return new CalendarDate(cal, dt); }
@JRubyMethod(optional = 1, visibility = Visibility.PRIVATE) public IRubyObject new_offset(ThreadContext context, IRubyObject[] args) { IRubyObject of = args.length > 0 ? args[0] : RubyFixnum.zero(context.runtime); final int off = val2off(context, of); DateTime dt = this.dt.withChronology(getChronology(context, start, off)); return newInstance(context, dt, off, start); }
@JRubyMethod(optional = 1, visibility = Visibility.PRIVATE) public IRubyObject new_offset(ThreadContext context, IRubyObject[] args) { IRubyObject of = args.length > 0 ? args[0] : RubyFixnum.zero(context.runtime); final int off = val2off(context, of); DateTime dt = this.dt.withChronology(getChronology(context, start, off)); return newInstance(context, dt, off, start); }
@Override public DateTimeUnit fromIso( DateTimeUnit dateTimeUnit ) { if ( !dateTimeUnit.isIso8601() ) { return dateTimeUnit; } DateTime dateTime = dateTimeUnit.toJodaDateTime( ISOChronology.getInstance( DateTimeZone.forTimeZone( dateTimeUnit.getTimeZone() ) ) ); dateTime = dateTime.withChronology( chronology ); return DateTimeUnit.fromJodaDateTime( dateTime ); }
@Override public DateTimeUnit toIso( DateTimeUnit dateTimeUnit ) { if ( dateTimeUnit.isIso8601() ) { return dateTimeUnit; } DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology ); dateTime = dateTime.withChronology( ISOChronology.getInstance( DateTimeZone.forTimeZone( dateTimeUnit.getTimeZone() ) ) ); return new DateTimeUnit( DateTimeUnit.fromJodaDateTime( dateTime ), true ); }