Here you can find the source of formatDateString(java.util.Date date, String format)
Parameter | Description |
---|---|
date | Given date. |
format | Given String ("dd-MM-yyyy" for 01-01-2000 format "dd-MMM-YYYY" for 01-Jan-2000 format) |
public static String formatDateString(java.util.Date date, String format)
//package com.java2s; import java.text.*; public class Main { /**/*from ww w . j a v a 2 s.co m*/ * Convert a date to required String format. * * @param date Given date. * @param format Given String ("dd-MM-yyyy" for 01-01-2000 format * "dd-MMM-YYYY" for 01-Jan-2000 format) * * @return Date in required format. */ public static String formatDateString(java.util.Date date, String format) { if ((date == null) || (format == null)) { return null; } // Set the date SimpleDateFormat fm = new SimpleDateFormat(format); return fm.format(date); } }