Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Hani Ibrahim
Added: Jan 30, 2017 5:23 PM
Modified: Aug 16, 2018 10:30 AM
Views: 42
ISO 8601 timestamp (e.g. 2017-01-01T14:10:23+0100), Java 6 compatible
  1.         /**
  2.      * Return a timestamp in ISO 8601, format: yyyy-MM-dd'T'HH:mm:ssZ
  3.      *
  4.      * @return ISO 8601 timestamp
  5.      */
  6.     static String getIsoTimestamp() {
  7.         TimeZone tz = TimeZone.getDefault();
  8.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
  9.         df.setTimeZone(tz);
  10.         return df.format(new Date()); // ISO 8601 Timestamp format
  11.     }