Java examples for java.util:Time Format
Get the current timestamp in a rfc-399 format.
import java.net.InetAddress; import java.net.UnknownHostException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.UUID; public class Main{ /**/*from w w w.jav a2s . c o m*/ * A rfc-399 formatter for dates. */ static final DateFormat rfc339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); /** * Get the current timestamp in a rfc-399 format. */ public static String getCurrentTimestampAsRfc339(){ return formatDateAsRfc339(getCurrentTimestamp()); } /** * Format a date in rfc-399 format. * @param date the non-null date. * @return the formatted date. */ public static String formatDateAsRfc339(Date date) { synchronized (MonitoringUtilities.class) { return rfc339.format(date); } } /** * Get the current timestamp. */ public static Date getCurrentTimestamp() { return new Date(); } }