Here you can find the source of getDay(java.util.Date date)
public static java.util.Date getDay(java.util.Date date)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static java.util.Date getDay(java.util.Date date) { java.util.Calendar cal = java.util.Calendar.getInstance(); cal.setTime(date);// w ww .j a va2 s .c om String s = new java.text.SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); try { return sf.parse(s); } catch (ParseException e) { return null; } } public static java.util.Date getDay(String date) { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); try { return sf.parse(date); } catch (ParseException e) { return null; } } public static String format(Date date, String pattern) { if (date == null) { return null; } SimpleDateFormat sf = new SimpleDateFormat(pattern); return sf.format(date); } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } public static Date parse(String dateStr) { return parse(dateStr, "yyyy-MM-dd"); } public static Date parse(String dateStr, String formate) { SimpleDateFormat sf = new SimpleDateFormat(formate); try { return sf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return null; } }