Here you can find the source of formatDate(Date date)
Formats the given date.
Parameter | Description |
---|---|
date | The Date to format. |
public static final String formatDate(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /**/*from w w w .j a va 2s. co m*/ * <p>Formats the given date.</p> * * @param date The Date to format. * * @return A String representing the formatted date. */ public static final String formatDate(Date date) { if (date == null) { throw new IllegalArgumentException("You must provide a date."); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(date); } }