Code example for SimpleDateFormat

Methods: formatsetTimeZone

0
 
	/** 
	 * Serializes a Date object to an ISO-8601 formatted date string 
	 */ 
	public static String serialize(Date date) {
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'", Locale.getDefault());
		dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
 
		String formatted = dateFormat.format(date);
 
		return formatted;
	} 
 
} 
Contextual code suggestions in your IDE  Get Codota for Java