Here you can find the source of formatDate(Date date, String format)
Parameter | Description |
---|---|
date | yyyymmdd |
format | a parameter |
public static String formatDate(Date date, String format)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**//from w w w.j a v a2 s . c o m * format date * * @param date yyyymmdd * @param format * @return */ public static String formatDate(Date date, String format) { SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US); String sysdate = formatter.format(date); return sysdate; } /** * format date * * @param date yyyymmdd * @param format * @return Date * @throws ParseException */ public static Date formatDate(String date, String format) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US); return formatter.parse(date); } }