Here you can find the source of dateToString(String date)
public static String dateToString(String date)
//package com.java2s; //License from project: Apache License public class Main { public static String dateToString(String date) { String stringDate = ""; if (date.length() == 10 && date.indexOf("-") > 0) { stringDate = getYYYYMMDD(date); } else {/*from w w w .j a v a 2s . co m*/ stringDate = date; } return stringDate; } public static String getYYYYMMDD(String date) { String YYYYMMDD = ""; YYYYMMDD = date.substring(0, 4) + date.substring(5, 7) + date.substring(8); return YYYYMMDD; } }