Here you can find the source of convertDateStringToString(String dateString, String format)
public static String convertDateStringToString(String dateString, String format)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String convertDateStringToString(String dateString, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = null;// w ww . j a va 2 s. co m String dateStr = ""; try { date = sdf.parse(dateString); dateStr = convertDateToStringByFormat(date); } catch (ParseException e) { e.printStackTrace(); } return dateStr; } public static String convertDateToStringByFormat(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } public static String convertDateToStringByFormat(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }