Here you can find the source of dateFormat(String datetime)
public static String dateFormat(String datetime)
//package com.java2s; //License from project: Apache License public class Main { public static String dateFormat(String datetime) { String date = ""; if (datetime != null && !"null".equals(datetime.trim()) && !"".equals(datetime.trim()) && datetime.length() > 10) { if ("00:00:00".equals(datetime.substring(11, 19))) { date = datetime.substring(0, 10); } else { date = datetime.substring(0, 19); }/* w ww. java 2 s .com*/ } else { date = datetime; } return date; } }