Here you can find the source of formateEndTimeString(String time)
public static String formateEndTimeString(String time)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String BASE_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String formateEndTimeString(String time) { return formateTimeString(time, "end"); }//from w w w. j a v a 2s . c om public static String formateTimeString(String time, String type) { if (time == null || time.length() < 10) { return ""; } if (time.length() < 14) { if (type.toLowerCase().equals("end")) { time += " 23:59:59"; } else { time += " 00:00:00"; } } SimpleDateFormat formatter = new SimpleDateFormat(BASE_PATTERN); Date myDate = null; try { myDate = formatter.parse(time); String timeStr = formatter.format(myDate); return timeStr; } catch (ParseException e) { e.printStackTrace(); return ""; } } public static String formateTimeString(String time) { return formateTimeString(time, "start"); } }