Here you can find the source of getFormatDate(String timeString, String format)
public static String getFormatDate(String timeString, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getFormatDate(String timeString, String format) { long timeLong = 0L; if (timeString == null || timeString.length() == 0) { timeLong = (new Date()).getTime(); } else {/*from ww w. j ava 2 s. c o m*/ timeLong = Long.valueOf(timeString).longValue(); } Date date = new Date(); date.setTime(timeLong); SimpleDateFormat simpledateformat = new SimpleDateFormat(format); return simpledateformat.format(date); } }