Time time; // you have this from your Database query DateTime dateTime; // you have this already or will create a new one Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time.getTime()); dateTime.setTime(calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE),calendar.get(Calendar.SECOND));
/** * Internal set of time by parsing value string. * @param value * @param format a {@code DateFormat}, protected by the use of a ThreadLocal. * @param tz * @throws ParseException */ private void setTime(final String value, final DateFormat format, final java.util.TimeZone tz) throws ParseException { if (tz != null) { format.setTimeZone(tz); } setTime(format.parse(value).getTime()); }
/** * Internal set of time by parsing value string. * * @param value * @param format * a {@code DateFormat}, protected by the use of a ThreadLocal. * @param tz * @throws ParseException */ private void setTime(final String value, final DateFormat format, final java.util.TimeZone tz) throws ParseException { if (tz != null) { format.setTimeZone(tz); } setTime(format.parse(value).getTime()); }
/** * Internal set of time by parsing value string. * * @param value * @param format * a {@code DateFormat}, protected by the use of a ThreadLocal. * @param tz * @throws ParseException */ private void setTime(final String value, final DateFormat format, final java.util.TimeZone tz) throws ParseException { if (tz != null) { format.setTimeZone(tz); } setTime(format.parse(value).getTime()); }
/** * Internal set of time by parsing value string. * * @param value * @param format * a {@code DateFormat}, protected by the use of a ThreadLocal. * @param tz * @throws ParseException */ private void setTime(final String value, final DateFormat format, final java.util.TimeZone tz) throws ParseException { if (tz != null) { format.setTimeZone(tz); } setTime(format.parse(value).getTime()); }
/** * Internal set of time by parsing value string. * * @param value * @param format * a {@code DateFormat}, protected by the use of a ThreadLocal. * @param tz * @throws ParseException */ private void setTime(final String value, final DateFormat format, final java.util.TimeZone tz) throws ParseException { if (tz != null) { format.setTimeZone(tz); } setTime(format.parse(value).getTime()); }
/** * @param value a string representation of a date-time * @param pattern a pattern to apply when parsing the date-time value * @param utc indicates whether the date-time is in UTC time * @throws ParseException where the specified string is not a valid date-time */ public DateTime(String value, String pattern, boolean utc) throws ParseException { this(); final DateFormat format = CalendarDateFormatFactory.getInstance(pattern); if (utc) { setTime(value, format, ((DateFormat) UTC_FORMAT.get()).getTimeZone()); } else { setTime(value, format, null); } setUtc(utc); }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
/** * @param value a string representation of a date-time * @param pattern a pattern to apply when parsing the date-time value * @param timezone the timezone for the date-time instance * @throws ParseException where the specified string is not a valid date-time */ public DateTime(String value, String pattern, TimeZone timezone) throws ParseException { // this(); super(Dates.PRECISION_SECOND, timezone != null ? timezone : java.util.TimeZone.getDefault()); this.time = new Time(getTime(), getFormat().getTimeZone()); final DateFormat format = CalendarDateFormatFactory.getInstance(pattern); setTime(value, format, timezone); }
/** * @param value * a string representation of a date-time * @param pattern * a pattern to apply when parsing the date-time value * @param timezone * the timezone for the date-time instance * @throws ParseException * where the specified string is not a valid date-time */ public DateTime(String value, String pattern, TimeZone timezone) throws ParseException { // setting the time to 0 since we are going to reset it anyway super(0, Dates.PRECISION_SECOND, timezone != null ? timezone : java.util.TimeZone.getDefault()); this.time = new Time(getTime(), getFormat().getTimeZone()); final DateFormat format = CalendarDateFormatFactory .getInstance(pattern); setTime(value, format, timezone); }
/** * @param value * a string representation of a date-time * @param pattern * a pattern to apply when parsing the date-time value * @param timezone * the timezone for the date-time instance * @throws ParseException * where the specified string is not a valid date-time */ public DateTime(String value, String pattern, TimeZone timezone) throws ParseException { // setting the time to 0 since we are going to reset it anyway super(0, Dates.PRECISION_SECOND, timezone != null ? timezone : java.util.TimeZone.getDefault()); this.time = new Time(getTime(), getFormat().getTimeZone()); final DateFormat format = CalendarDateFormatFactory .getInstance(pattern); setTime(value, format, timezone); }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - getOffsetFrom().getOffset().getOffset()); return withOffset; } }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - (getOffsetFrom().getOffset().getTotalSeconds() * 1000L)); return withOffset; } }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - (getOffsetFrom().getOffset().getTotalSeconds() * 1000L)); return withOffset; } }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - getOffsetFrom().getOffset().getOffset()); return withOffset; } }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - getOffsetFrom().getOffset().getOffset()); return withOffset; } }