Here you can find the source of formatDateFromStringToString(String str)
public static String formatDateFromStringToString(String str)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static String formatDateFromStringToString(String str) { SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sf2 = new SimpleDateFormat("yyyy-MM-dd"); try {//from ww w. jav a2s . c om return sf2.format(sf1.parse(str)); } catch (ParseException e) { return ""; } } }