Here you can find the source of toISOString(Date date, String format, TimeZone tz)
Parameter | Description |
---|---|
date | the date obj |
format | - if not specified, will use FORMAT_DATE_ISO |
tz | - tz to set to, if not specified uses local timezone |
public static String toISOString(Date date, String format, TimeZone tz)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** The date format in ISO. */ public static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'"; /**//from w w w. j a va 2 s .c o m * Render date * * @param date * the date obj * @param format * - if not specified, will use FORMAT_DATE_ISO * @param tz * - tz to set to, if not specified uses local timezone * @return the ISO-formatted date string */ public static String toISOString(Date date, String format, TimeZone tz) { if (format == null) { format = FORMAT_DATE_ISO; } if (tz == null) { tz = TimeZone.getDefault(); } DateFormat f = new SimpleDateFormat(format); f.setTimeZone(tz); return f.format(date); } public static String toISOString(Date date) { return toISOString(date, FORMAT_DATE_ISO, TimeZone.getDefault()); } }