Here you can find the source of dateToStr(Date date, String formatType)
static String dateToStr(Date date, String formatType)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { static String dateToStr(Date date, String formatType) { return longTypeToStr(date.getTime(), formatType); }//ww w. j a v a2 s . co m static String longTypeToStr(long time, String formatType) { String strTime = ""; if (time > 0) { SimpleDateFormat sDateFormat = new SimpleDateFormat(formatType); strTime = sDateFormat.format(new Date(time)); } return strTime; } }