Here you can find the source of dateToStr(Date date, String formatstr)
public static String dateToStr(Date date, String formatstr)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss"; public static String dateToStr(Date date) { SimpleDateFormat format = new SimpleDateFormat(yyyyMMddHHmmss); return format.format(date); }/*from w w w .ja va 2s. c o m*/ public static String dateToStr(Date date, String formatstr) { SimpleDateFormat format = new SimpleDateFormat(formatstr); return format.format(date); } }