/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ @Override protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); } }
/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ @Override protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); }
/** * Parse a String into a <code>Calendar</code> object * using the specified <code>DateFormat</code>. * * @param sourceType The type of the value being converted * @param targetType The type to convert the value to * @param value The String date value. * @param format The DateFormat to parse the String value. * * @return The converted Calendar object. * @throws ConversionException if the String cannot be converted. */ private Calendar parse(final Class<?> sourceType, final Class<?> targetType, final String value, final DateFormat format) { logFormat("Parsing", format); format.setLenient(false); final ParsePosition pos = new ParsePosition(0); final Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar) if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) { String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'"; if (format instanceof SimpleDateFormat) { msg += " using pattern '" + ((SimpleDateFormat)format).toPattern() + "'"; } if (log().isDebugEnabled()) { log().debug(" " + msg); } throw new ConversionException(msg); } final Calendar calendar = format.getCalendar(); return calendar; }
/** * Parse a String into a <code>Calendar</code> object * using the specified <code>DateFormat</code>. * * @param sourceType The type of the value being converted * @param targetType The type to convert the value to * @param value The String date value. * @param format The DateFormat to parse the String value. * * @return The converted Calendar object. * @throws ConversionException if the String cannot be converted. */ private Calendar parse(final Class<?> sourceType, final Class<?> targetType, final String value, final DateFormat format) { logFormat("Parsing", format); format.setLenient(false); final ParsePosition pos = new ParsePosition(0); final Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar) if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) { String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'"; if (format instanceof SimpleDateFormat) { msg += " using pattern '" + ((SimpleDateFormat)format).toPattern() + "'"; } if (log().isDebugEnabled()) { log().debug(" " + msg); } throw new ConversionException(msg); } final Calendar calendar = format.getCalendar(); return calendar; }
return localSimpleDateFormat.get().getCalendar();
/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ @Override protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); }
/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ @Override protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); } }
/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); } }
/** * <p>Convert the parsed <code>Date</code> to a <code>Calendar</code>.</p> * * @param value The parsed <code>Date</code> object created. * @param formatter The Format used to parse the value with. * @return The parsed value converted to a <code>Calendar</code>. */ protected Object processParsedValue(Object value, Format formatter) { return ((DateFormat)formatter).getCalendar(); }
private static Calendar parseXEP91Date(String stampString, DateFormat dateFormat) { try { dateFormat.parse(stampString); return dateFormat.getCalendar(); } catch (ParseException e) { return null; } }
private static Calendar parseXEP91Date(String stampString, DateFormat dateFormat) { try { synchronized (dateFormat) { dateFormat.parse(stampString); return dateFormat.getCalendar(); } } catch (ParseException e) { return null; } }
private Calendar parseXEP91Date(String stampString, DateFormat dateFormat) { try { synchronized (dateFormat) { dateFormat.parse(stampString); return dateFormat.getCalendar(); } } catch (ParseException e) { return null; } }
String input_format = "EEE MMMMM dd HH:mm:ss Z yyyy"; String input_value="Wed Jun 13 17:05:44 +0000 2012"; Date date=null; SimpleDateFormat sdf = new SimpleDateFormat(input_format); try { date = sdf.parse(input_value); } catch (ParseException e) { e.printStackTrace(); } Calendar calendar = sdf.getCalendar(); calendar.setTime(date);
public long getTimestampAsLong() { DateFormat dfm = new SimpleDateFormat(DEFAULT_TIME_STAMP); try { dfm.parse(testTimestampBefore); Calendar c = dfm.getCalendar(); c.add(Calendar.DAY_OF_MONTH, 1); return c.getTimeInMillis(); } catch (ParseException e) { return -1; } }
public static Calendar parseDateTime(String dateTime) throws ParseException { synchronized (dateTimeFormat) { try { Calendar calendar = (Calendar) dateTimeFormat.getCalendar().clone(); calendar.setTime(dateTimeFormat.parse(dateTime)); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); return calendar; } catch (Throwable e) { throw new ParseException("Failed to parse date/time string \"" + dateTime + "\".", 0); } } }
DateFormat originalDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); DateFormat targetDateFormat = new SimpleDateFormat("EEE., MMM. dd, yyyy"); originalDateFormat.parse(origDateString); targetDateFormat.setCalendar(originalDateFormat.getCalendar()); return targetDateFormat.format(targetDateFormat.getCalendar().getTime());
private Calendar parse(String value, DateFormat format) { format.setLenient(false); ParsePosition pos = new ParsePosition(0); java.util.Date parsedDate = format.parse(value, pos); if ((pos.getErrorIndex() >= 0) || (pos.getIndex() != value.length()) || (parsedDate == null)) { throw new RuntimeException("Can not format " + value + " to:" + format); } return format.getCalendar(); }
@Override public Calendar getCalendar() { return delegate.get().getCalendar(); }
/** * Returns the calendar associated with this date/time formatter. * @return the calendar associated with this date/time formatter. * @stable ICU 2.0 */ public Calendar getCalendar() { return new Calendar(dateFormat.getCalendar()); }
public java.util.Calendar getCalendar() { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, "getCalendar", "()Ljava/util/Calendar;", new Object[] {}); java.util.Calendar ret = new Calendar(super.getCalendar()); Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, ret); return ret; }