Java Utililty Methods Date Format ISO

List of utility methods to do Date Format ISO

Description

The list of methods to do Date Format ISO are organized into topic(s).

Method

StringgetDateAsISOString(Date date)
Creates a string representation of the a date.
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return DatatypeConverter.printDateTime(cal);
StringgetFormattedMillisolString(double s)
get Formatted Millisol String
s = s * 3_600_000.0 / SECONDS_PER_SOLAR_DAY_ON_MARS;
return new DecimalFormat("###.###").format(s);
StringgetIso8601(final Date date)
Gets the date and time in ISO8601 format with time zone formatted as Z (UTC), +hh:mm, or -hh:mm.
final DateFormat outputDateFormat = createDateFormat(DATE_FORMAT_PATTERN);
final String preformatted = outputDateFormat.format(date);
return preformatted.endsWith("Z") ? preformatted
        : preformatted.endsWith("+0000")
                ? preformatted.substring(0, preformatted.length() - "+0000".length()) + 'Z'
                : preformatted.substring(0, preformatted.length() - 2) + ':'
                        + preformatted.substring(preformatted.length() - 2, preformatted.length());
StringgetISO8601Date(final Date date)
get an ISO 8601 Date Format
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
return sdf.format(date);
StringgetISO8601Date(long millis)
Get valid ISO 8601 date out of a given time in milliseconds.
return iso8601Formatter.format(new Date(millis));
DateFormatgetIso8601DateFormat()
get Iso Date Format
SimpleDateFormat df = new SimpleDateFormat(ISO8601_DATE_FORMAT, Locale.US);
df.setTimeZone(new SimpleTimeZone(0, "GMT"));
return df;
DateFormatgetIso8601DateFormat()
get Iso Date Format
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.Sz");
SimpleDateFormatgetIso8601DateFormat()
get Iso Date Format
return iso8601DateFormat;
DateFormatgetISO8601DateFormat()
get ISO Date Format
DateFormat dateFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT);
dateFormat.setTimeZone(UTC);
return dateFormat;
SimpleDateFormatgetIso8601DateFormat()
get Iso Date Format
final SimpleDateFormat ISO8601UTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
ISO8601UTC.setTimeZone(TimeZone.getTimeZone("UTC")); 
return ISO8601UTC;