private static boolean checkInvalidDate() { final String input = "2014-03-06T14:28:58.000Z.000Z"; try { DateUtils.doParseISO8601Date(input); return false; } catch (RuntimeException expected) { } return true; } }
private static boolean checkFormatIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String expected = sdf.format(date); String actual = DateUtils.iso8601DateFormat.print(date.getTime()); if (expected.equals(actual)) { Date expectedDate = sdf.parse(expected); Date actualDate = DateUtils.doParseISO8601Date(actual); return expectedDate.equals(actualDate); } return false; }
private static boolean checkParseIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String formatted = sdf.format(date); String alternative = DateUtils.iso8601DateFormat.print(date.getTime()); if (formatted.equals(alternative)) { Date expectedDate = sdf.parse(formatted); Date actualDate = DateUtils.doParseISO8601Date(formatted); return expectedDate.equals(actualDate); } return false; }
/** * Parses the specified date string as an ISO 8601 date and returns the Date * object. * * @param dateString * The date string to parse. * * @return The parsed Date object. */ public static Date parseISO8601Date(String dateString) { try { return doParseISO8601Date(dateString); } catch(RuntimeException ex) { throw handleException(ex); } }
private static boolean checkInvalidDate() { final String input = "2014-03-06T14:28:58.000Z.000Z"; try { DateUtils.doParseISO8601Date(input); return false; } catch (RuntimeException expected) { } return true; } }
private static boolean checkFormatIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String expected = sdf.format(date); String actual = DateUtils.iso8601DateFormat.print(date.getTime()); if (expected.equals(actual)) { Date expectedDate = sdf.parse(expected); Date actualDate = DateUtils.doParseISO8601Date(actual); return expectedDate.equals(actualDate); } return false; }
private static boolean checkParseIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String formatted = sdf.format(date); String alternative = DateUtils.iso8601DateFormat.print(date.getTime()); if (formatted.equals(alternative)) { Date expectedDate = sdf.parse(formatted); Date actualDate = DateUtils.doParseISO8601Date(formatted); return expectedDate.equals(actualDate); } return false; }
/** * Parses the specified date string as an ISO 8601 date and returns the Date * object. * * @param dateString * The date string to parse. * * @return The parsed Date object. */ public static Date parseISO8601Date(String dateString) { try { return doParseISO8601Date(dateString); } catch(RuntimeException ex) { throw handleException(ex); } }
private static boolean checkInvalidDate() { final String input = "2014-03-06T14:28:58.000Z.000Z"; try { DateUtils.doParseISO8601Date(input); return false; } catch (RuntimeException expected) { } return true; } }
private static boolean checkFormatIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String expected = sdf.format(date); String actual = DateUtils.iso8601DateFormat.print(date.getTime()); if (expected.equals(actual)) { Date expectedDate = sdf.parse(expected); Date actualDate = DateUtils.doParseISO8601Date(actual); return expectedDate.equals(actualDate); } return false; }
private static boolean checkParseIso8601Date() throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(new SimpleTimeZone(0, "GMT")); String formatted = sdf.format(date); String alternative = DateUtils.iso8601DateFormat.print(date.getTime()); if (formatted.equals(alternative)) { Date expectedDate = sdf.parse(formatted); Date actualDate = DateUtils.doParseISO8601Date(formatted); return expectedDate.equals(actualDate); } return false; }
/** * Parses the specified date string as an ISO 8601 date and returns the Date * object. * * @param dateString * The date string to parse. * * @return The parsed Date object. */ public static Date parseISO8601Date(String dateString) { try { return doParseISO8601Date(dateString); } catch(RuntimeException ex) { throw handleException(ex); } }