Here you can find the source of format(Date date)
Parameter | Description |
---|---|
date | the date |
public static String format(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { /** The Constant UTC_TIME_ZONE. */ public final static TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC"); /** The Constant DATE_TIME_PATTERN. */ public final static String DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; /**// ww w. ja v a2 s .co m * Format the date. * * @param date the date * @return the formated date */ public static String format(Date date) { DateFormat df = getThreadLocalDateFormat(); return df.format(date); } /** * Format the date. * * @param current the current * @return the string */ public static String format(Calendar current) { return format(current.getTime()); } /** * Gets the thread local date format. * * @return the thread local date format */ private static DateFormat getThreadLocalDateFormat() { DateFormat result = new SimpleDateFormat(DATE_TIME_PATTERN); result.setTimeZone(UTC_TIME_ZONE); return result; } }