Here you can find the source of dateFormat(String date)
public static String dateFormat(String date)
//package com.java2s; //License from project: Open Source License public class Main { public static String dateFormat(String date) { if (date.length() == 10) { return date.substring(0, 2) + "-" + date.substring(2, 4) + ' ' + date.substring(4, 6) + ':' + date.substring(6, 8) + ':' + date.substring(8, 10); } else if (date.length() == 8) { return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8); } else if (date.length() == 6) { return date.substring(0, 2) + ":" + date.substring(2, 4) + ":" + date.substring(4, 6); } else if (date.length() == 4) { return date.substring(0, 2) + ":" + date.substring(2, 4); } else if (date.length() == 14) { return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + ' ' + date.substring(8, 10) + ":" + date.substring(10, 12) + ":" + date.substring(12, 14); /*/*from ww w . j av a 2 s .c om*/ * try { date = * showDateFormatZHCN.format(sysDateFormat.parse(date)); } catch * (ParseException e) { e.printStackTrace(); } return date; */ } else { return date; } } }