ISO8601DateFormat df = new ISO8601DateFormat(); Date d = df.parse("2010-07-28T22:25:51Z");
public static String getFormattedDate(String isoDateTime){ ISO8601DateFormat df = new ISO8601DateFormat(); Date date=new Date(); try { date = df.parse(isoDateTime); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat simpleDateFormat=new SimpleDateFormat("hh:mm aaa, EEEE, d-MMM-yyyy"); String dateString=simpleDateFormat.format(date); return dateString; }
private Date getDate(Serializable value) { if(value instanceof Date) { return (Date) value; } else if(value instanceof String) { return ISO8601DateFormat.parse((String) value); } throw new AlfrescoRuntimeException("Parameter 'compareValue' must be of type java.util.Date!"); }
private Date getDate(Serializable value) { if(value instanceof Date) { return (Date) value; } else if(value instanceof String) { return ISO8601DateFormat.parse((String) value); } throw new AlfrescoRuntimeException("Parameter 'compareValue' must be of type java.util.Date!"); }
if(createdAtStr != null) createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr): null);
if(createdAtStr != null) createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr): null);
public void testConversion() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); String test = "2005-09-16T17:01:03.456+01:00"; String test2 = "1801-09-16T17:01:03.456+01:00"; // convert to a date Date date = ISO8601DateFormat.parse(test); Date date2 = ISO8601DateFormat.parse(test2); // get the string form String strDate = ISO8601DateFormat.format(date); String strDate2 = ISO8601DateFormat.format(date2); // convert back to a date from the converted string Date dateAfter = ISO8601DateFormat.parse(strDate); Date dateAfter2 = ISO8601DateFormat.parse(strDate2); // 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); assertEquals(date2, dateAfter2); }
String prefKey = builder.toString(); String createdAtStr = (String)preferenceService.getPreference(userName, prefKey); Date createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr): null);
String prefKey = builder.toString(); String createdAtStr = (String)preferenceService.getPreference(userName, prefKey); Date createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr): null);
String testCms = "1801-09-16T17:01:03.000Z"; Date dateA = ISO8601DateFormat.parse(testA); Date dateB = ISO8601DateFormat.parse(testB); Date dateC = ISO8601DateFormat.parse(testC); String testCms7 = "2005-09-16T17:01:03.1234567+01:00"; Date testCDate = ISO8601DateFormat.parse(testCms3); assertEquals(testCDate, ISO8601DateFormat.parse(testCms4)); assertEquals(testCDate, ISO8601DateFormat.parse(testCms5)); assertEquals(testCDate, ISO8601DateFormat.parse(testCms6)); assertEquals(testCDate, ISO8601DateFormat.parse(testCms7));
public void testTimezones() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); Date date = null; TimeZone tz = TimeZone.getTimeZone("Australia/Sydney"); String testSydney = "2011-02-04T16:13:14"; String testUTC = "2011-02-04T05:13:14.000Z"; //Sydney date = ISO8601DateFormat.parse(testSydney, tz); assertEquals(testUTC, ISO8601DateFormat.format(date)); // Check with ms too date = ISO8601DateFormat.parse(testSydney + ".000", tz); assertEquals(testUTC, ISO8601DateFormat.format(date)); //Sydney with an offset and timezone date = ISO8601DateFormat.parse(testSydney+"+11:00", tz); assertEquals(testUTC, ISO8601DateFormat.format(date)); // Check with ms too date = ISO8601DateFormat.parse(testSydney + ".000"+"+11:00", tz); assertEquals(testUTC, ISO8601DateFormat.format(date)); }
ISO8601DateFormat.parse(isoDate);
ISO8601DateFormat.parse(isoDate);
Date createdAt = (createdAtStr == null ? null : ISO8601DateFormat.parse(createdAtStr));
Date createdAt = (createdAtStr == null ? null : ISO8601DateFormat.parse(createdAtStr));
public void testDateParser() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); String test = "2005-09-16T17:01:03.456+01:00"; String test2 = "1801-09-16T17:01:03.456+01:00"; String isoFormattedDate = "2005-09-16T16:01:03.456Z"; String isoFormattedDate2 = "1801-09-16T16:01:03.456Z"; Date testDate = getDateValue(2005, 9, 16, 17, 1, 3, 456, 60); Date testDate2 = getDateValue(1801, 9, 16, 17, 1, 3, 456, 60); // convert to a date Date date = ISO8601DateFormat.parse(test); Date date2 = ISO8601DateFormat.parse(test2); // check converted to date value assertEquals(testDate, date); assertEquals(testDate2, date2); // get the string form String strDate = ISO8601DateFormat.format(date); String strDate2 = ISO8601DateFormat.format(date2); // check the date converted to sting assertEquals(isoFormattedDate, strDate); assertEquals(isoFormattedDate2, strDate2); }
assertEquals(c3.getStart(), ISO8601DateFormat.parse(filtered.get(0).getFromDate(),utc)); assertEquals(c3.getEnd(), ISO8601DateFormat.parse(filtered.get(0).getToDate(),utc)); assertEquals(c3.getRecurrenceRule(), filtered.get(0).getRecurrenceRule()); assertEquals(null, filtered.get(0).getRecurrenceLastMeeting()); assertEquals(c1.getStart(), ISO8601DateFormat.parse(filtered.get(1).getFromDate(),utc)); assertEquals(c1.getEnd(), ISO8601DateFormat.parse(filtered.get(1).getToDate(),utc)); assertEquals(c1.getRecurrenceRule(), filtered.get(1).getRecurrenceRule()); assertEquals(null, filtered.get(1).getRecurrenceLastMeeting()); assertEquals(c2.getStart(), ISO8601DateFormat.parse(filtered.get(2).getFromDate(),utc)); assertEquals(c2.getEnd(), ISO8601DateFormat.parse(filtered.get(2).getToDate(),utc)); assertEquals(c2.getRecurrenceRule(), filtered.get(2).getRecurrenceRule()); assertEquals(null, filtered.get(2).getRecurrenceLastMeeting()); assertEquals(c3.getStart(), ISO8601DateFormat.parse(filtered.get(0).getFromDate(),utc)); assertEquals(c3.getEnd(), ISO8601DateFormat.parse(filtered.get(0).getToDate(),utc)); assertEquals(c3.getLastRecurrence(), ISO8601DateFormat.parse(filtered.get(0).getRecurrenceLastMeeting(),utc)); assertEquals(c3.getRecurrenceRule(), filtered.get(0).getRecurrenceRule()); assertEquals(c1.getStart(), ISO8601DateFormat.parse(filtered.get(1).getFromDate(),utc)); assertEquals(c1.getEnd(), ISO8601DateFormat.parse(filtered.get(1).getToDate(),utc)); assertEquals(c1.getRecurrenceRule(), filtered.get(1).getRecurrenceRule()); assertEquals(null, filtered.get(1).getRecurrenceLastMeeting());