Here you can find the source of toDateString(Date date, String format)
Parameter | Description |
---|---|
date | the date |
format | the format |
public static String toDateString(Date date, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** The Constant DD_MMM_YYYY. */ public static final String YYYYMMDDHHMMSSZ = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; /**//from www . j a v a 2 s. co m * Date converted to string in specified format. * * @param date * the date * @param format * the format * @return the string */ public static String toDateString(Date date, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.format(date); } /** * Date converted to string in default (dd-MMM-yyyy) format. * * @param date * the date * @return the string */ public static String toDateString(Date date) { return toDateString(date, YYYYMMDDHHMMSSZ); } }