/** * Parse date from ISO formatted string * * @param isoDateString String * @return Date */ public Date fromISO8601(String isoDateString) { return ISO8601DateFormat.parse(isoDateString); }
/** * Parse date from ISO formatted string * * @param isoDateString String * @return Date */ public Date fromISO8601(String isoDateString) { return ISO8601DateFormat.parse(isoDateString); }
o = ISO8601DateFormat.parse((String)o);
o = ISO8601DateFormat.parse((String)o);
o = ISO8601DateFormat.parse((String)o);
o = ISO8601DateFormat.parse((String)o);
/** * @see freemarker.template.TemplateMethodModel#exec(java.util.List) */ public Object exec(List args) throws TemplateModelException { Object result = null; if (args.size() == 1) { Object arg0 = args.get(0); if (arg0 instanceof TemplateDateModel) { result = ISO8601DateFormat.format(((TemplateDateModel)arg0).getAsDate()); } else if (arg0 instanceof TemplateScalarModel) { result = ISO8601DateFormat.parse(((TemplateScalarModel)arg0).getAsString()); } } return result != null ? result : ""; } }
/** * @see freemarker.template.TemplateMethodModel#exec(java.util.List) */ public Object exec(List args) throws TemplateModelException { Object result = null; if (args.size() == 1) { Object arg0 = args.get(0); if (arg0 instanceof TemplateDateModel) { result = ISO8601DateFormat.format(((TemplateDateModel)arg0).getAsDate()); } else if (arg0 instanceof TemplateScalarModel) { result = ISO8601DateFormat.parse(((TemplateScalarModel)arg0).getAsString()); } } return result != null ? result : ""; } }
/** * @see freemarker.template.TemplateMethodModel#exec(java.util.List) */ public Object exec(List args) throws TemplateModelException { Object result = null; if (args.size() == 1) { Object arg0 = args.get(0); if (arg0 instanceof TemplateDateModel) { result = ISO8601DateFormat.format(((TemplateDateModel)arg0).getAsDate()); } else if (arg0 instanceof TemplateScalarModel) { result = ISO8601DateFormat.parse(((TemplateScalarModel)arg0).getAsString()); } } return result != null ? result : ""; } }
/** * @see freemarker.template.TemplateMethodModel#exec(java.util.List) */ public Object exec(List args) throws TemplateModelException { Object result = null; if (args.size() == 1) { Object arg0 = args.get(0); if (arg0 instanceof TemplateDateModel) { result = ISO8601DateFormat.format(((TemplateDateModel)arg0).getAsDate()); } else if (arg0 instanceof TemplateScalarModel) { result = ISO8601DateFormat.parse(((TemplateScalarModel)arg0).getAsString()); } } return result != null ? result : ""; } }
/** * @see freemarker.template.TemplateMethodModel#exec(java.util.List) */ public Object exec(List args) throws TemplateModelException { Object result = null; if (args.size() == 1) { Object arg0 = args.get(0); if (arg0 instanceof TemplateDateModel) { result = ISO8601DateFormat.format(((TemplateDateModel)arg0).getAsDate()); } else if (arg0 instanceof TemplateScalarModel) { result = ISO8601DateFormat.parse(((TemplateScalarModel)arg0).getAsString()); } } return result != null ? result : ""; } }
public void testConversion() { String test = "2005-09-16T17:01:03.456+01:00"; // convert to a date Date date = ISO8601DateFormat.parse(test); // get the string form String strDate = ISO8601DateFormat.format(date); // convert back to a date from the converted string Date dateAfter = ISO8601DateFormat.parse(strDate); // make sure the date objects match, test this instead of the // string as the string form will be different in different // locales assertEquals(date, dateAfter); } }
header.setCreatedDate(ISO8601DateFormat.parse(buffer.toString())); buffer = null;
header.setCreatedDate(ISO8601DateFormat.parse(buffer.toString())); buffer = null;
try installDate = ISO8601DateFormat.parse(installDateStr);
try installDate = ISO8601DateFormat.parse(installDateStr);
@Test public void testPropertyDateValue() throws Exception { final Date dateValue = ISO8601DateFormat.parse("1936-08-04T23:37:25.793Z"); final Date dateValueBack = ISO8601DateFormat.parse("1936-08-04T00:00:00.000Z"); RetryingTransactionCallback<Pair<Long, Date>> createValueCallback = new RetryingTransactionCallback<Pair<Long, Date>>() { public Pair<Long, Date> execute() throws Throwable { return propertyValueDAO.getOrCreatePropertyDateValue(dateValue); } }; final Pair<Long, Date> entityPair = txnHelper.doInTransaction(createValueCallback, false); assertNotNull(entityPair); assertEquals(dateValueBack, entityPair.getSecond()); RetryingTransactionCallback<Pair<Long, Date>> getValueCallback = new RetryingTransactionCallback<Pair<Long, Date>>() { public Pair<Long, Date> execute() throws Throwable { return propertyValueDAO.getPropertyDateValue(dateValue); } }; final Pair<Long, Date> entityPairCheck = txnHelper.doInTransaction(getValueCallback, false); assertNotNull(entityPairCheck); assertEquals(entityPair, entityPairCheck); }
String modifier = DefaultTypeConverter.INSTANCE.convert(String.class, nodeProps.get(ContentModel.PROP_MODIFIER)); assertEquals("cm:created not preserved during import", ISO8601DateFormat.format(ISO8601DateFormat.parse("2009-04-30T23:00:00.000Z")), createdDate); assertEquals("cm:creator not preserved during import", "Import Creator", creator); assertEquals("cm:modified not preserved during import", ISO8601DateFormat.format(ISO8601DateFormat.parse("2009-05-01T23:00:00.000Z")), modifiedDate); assertEquals("cm:modifier not preserved during import", "Import Modifier", modifier); modifier = DefaultTypeConverter.INSTANCE.convert(String.class, nodeProps.get(ContentModel.PROP_MODIFIER)); assertEquals("cm:created not preserved during import", ISO8601DateFormat.format(ISO8601DateFormat.parse("2009-04-30T23:00:00.000Z")), createdDate); assertEquals("cm:creator not preserved during import", "Import Creator", creator); assertEquals("cm:modifier not preserved during import", AuthenticationUtil.getSystemUserName(), modifier);