final Object parsedValue = formatter.parseObject(strValue, pos); if (pos.getErrorIndex() > -1) { throw new ConversionException("Error parsing date '" + value +
final Object parsedValue = formatter.parseObject(strValue, pos); if (pos.getErrorIndex() > -1) { throw new ConversionException("Error parsing date '" + value +
dfFormatter = new SimpleDateFormat( sArg2, dfLocale ); dfFormatter.setTimeZone( tz ); oRC = dfFormatter.parseObject( sArg1 ); } else { throw new RuntimeException( "Locale " + sArg3 + " is not 2 characters long." );
return localSimpleDateFormat.get().parseObject(source, pos);
dfFormatter = new SimpleDateFormat( sArg2, dfLocale ); dfFormatter.setTimeZone( tz ); oRC = dfFormatter.parseObject( sArg1 ); } else { throw Context.reportRuntimeError( "Locale " + sArg3 + " is not 2 characters long." );
public Object convertFormValueToModelValue(Object propertyValue) { if (propertyValue==null || "".equals(propertyValue)) { return null; } try { return dateFormat.parseObject(propertyValue.toString()); } catch (ParseException e) { throw new ProcessEngineException("invalid date value "+propertyValue); } }
public Object convertFormValueToModelValue(Object propertyValue) { if (propertyValue==null || "".equals(propertyValue)) { return null; } try { return dateFormat.parseObject(propertyValue.toString()); } catch (ParseException e) { throw new ProcessEngineException("invalid date value "+propertyValue); } }
public TypedValue convertToModelValue(TypedValue propertyValue) { Object value = propertyValue.getValue(); if(value == null) { return Variables.dateValue(null, propertyValue.isTransient()); } else if(value instanceof Date) { return Variables.dateValue((Date) value, propertyValue.isTransient()); } else if(value instanceof String) { String strValue = ((String) value).trim(); if (strValue.isEmpty()) { return Variables.dateValue(null, propertyValue.isTransient()); } try { return Variables.dateValue((Date) dateFormat.parseObject(strValue), propertyValue.isTransient()); } catch (ParseException e) { throw new ProcessEngineException("Could not parse value '"+value+"' as date using date format '"+datePattern+"'."); } } else { throw new ProcessEngineException("Value '"+value+"' cannot be transformed into a Date."); } }
public TypedValue convertToModelValue(TypedValue propertyValue) { Object value = propertyValue.getValue(); if(value == null) { return Variables.dateValue(null, propertyValue.isTransient()); } else if(value instanceof Date) { return Variables.dateValue((Date) value, propertyValue.isTransient()); } else if(value instanceof String) { String strValue = ((String) value).trim(); if (strValue.isEmpty()) { return Variables.dateValue(null, propertyValue.isTransient()); } try { return Variables.dateValue((Date) dateFormat.parseObject(strValue), propertyValue.isTransient()); } catch (ParseException e) { throw new ProcessEngineException("Could not parse value '"+value+"' as date using date format '"+datePattern+"'."); } } else { throw new ProcessEngineException("Value '"+value+"' cannot be transformed into a Date."); } }
public Object revert(Object o) { try { return dateFormat.parseObject((String) o); } catch (ParseException e) { throw new PvmException("invalid date format in date variable: " + o, e); } }
@Override public Object parseObject(final String source, final ParsePosition pos) { return delegate.get().parseObject(source, pos); }
@Override public Object parseObject(final String source) throws ParseException { return delegate.get().parseObject(source); }
public Object convertFormValueToModelValue(Object propertyValue) { if (propertyValue==null || "".equals(propertyValue)) { return null; } try { return dateFormat.parseObject(propertyValue.toString()); } catch (ParseException e) { throw new ProcessEngineException("invalid date value "+propertyValue); } }
public Object revert(Object o) { try { return dateFormat.parseObject((String)o); } catch (ParseException e) { throw new PvmException("invalid date format in date variable: "+o, e); } }
@Override public Object parseObject(String source) throws ParseException { return get().parseObject(source); }
@Override public Object parseObject(String source, ParsePosition pos) { return get().parseObject(source, pos); }
protected Date convertValue( final String text ) { if ( StringUtils.isEmpty( text ) ) { return null; } try { final Date o = (Date) sdf.parseObject( text ); // this magic converts the date or number value to the real type. // the formatter always returns doubles/bigdecimals or java.util.Dates // but we may need sql-dates, long-objects etc .. return DateConverter.convertToDateType( o, dateType ); } catch ( ParseException e ) { throw new RuntimeException( "Failed to format object", e ); } }
/** * Uses the current locale (user) to parse the date and time. * * @param dateStr Date or Calendar * @return the String */ public static Date parseDateTime(String dateStr) throws ParseException { DateFormat format = SimpleDateFormat.getDateTimeInstance( FastDateFormat.SHORT, FastDateFormat.SHORT, MgnlContext.getLocale()); return (Date) format.parseObject(dateStr); }
/** {@inheritDoc} */ public Date getDate() throws ConversionException { if (isEmpty()) { return null; } String str = getText(); ParsePosition posInOut = new ParsePosition(0); Date result = (Date)format.parseObject(str, posInOut); if (posInOut.getIndex() == str.length()) { return result; } else { throw new ConversionException(); } }
public Object parseObject(String source, ParsePosition pos) { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, "parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Object;", new Object[] {source, pos}); Object ret = super.parseObject(source, pos); if(ret instanceof java.util.Date) { long time = ((java.util.Date)ret).getTime(); ret = new Date(time); } Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, this, ret); return ret; }