Here you can find the source of toDate()
public static String toDate()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static final String DEFAULT_DATE_FORMATE = "yyyy-MM-dd HH:mm:ss"; public static String toDate() { return toDate(new Date()); }/* w w w. j a va2 s . c om*/ public static String toDate(Date dt) { SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATE_FORMATE); df.setTimeZone(TimeZone.getDefault()); return df.format(dt); } }