Here you can find the source of parseDate(Date date)
Parameter | Description |
---|---|
date | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static String parseDate(Date date) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**/* w w w.j a v a 2 s . co m*/ * * @param date * @return * @throws ParseException */ public static Date parseDate(String date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(date)); return cal.getTime(); } /** * * @param date * @return * @throws ParseException */ public static String parseDate(Date date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date); } }