Here you can find the source of getDateString(Calendar calendar)
public static String getDateString(Calendar calendar)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static String getDateString(Calendar calendar) { StringBuffer sb = new StringBuffer(); sb.append(calendar.get(Calendar.YEAR)).append("-"); int month = calendar.get(Calendar.MONTH) + 1; if (month < 10) sb.append("0"); sb.append(month).append("-"); int day = calendar.get(Calendar.DAY_OF_MONTH); if (day < 10) sb.append("0"); sb.append(day);/*from w ww.ja va2 s. c o m*/ return sb.toString(); } public static final String getDateString(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); return getDateString(calendar); } }