Here you can find the source of toDateString(long ms)
public static String toDateString(long ms)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String toDateString(long ms) { return format(ms, "yyyy-MM-dd"); }//from w w w. ja v a2 s . c om public static String toDateString(Date date) { return toDateString(date.getTime()); } public static String format(long ms, String pattern) { DateFormat df = new SimpleDateFormat(pattern); return df.format(new Date(ms)); } }