Here you can find the source of convertToDate(String str)
public static String convertToDate(String str) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static String convertToDate(String str) throws ParseException { if (str == null) return null; SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); return sdf.format(sdf1.parse(str)); }/*from w w w. j a va2 s . c o m*/ }