Here you can find the source of getTimeMax(Date date)
public static Date getTimeMax(Date date)
//package com.java2s; //License from project: Apache License import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); public static final String DATE_FORMAT_1 = "yyyy-MM-dd HH:mm:ss"; public static Date getTimeMax(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String da = sdf.format(date); da = da + " 23:59:59"; Date d = getStrToDate(DATE_FORMAT_1, da); return d; }//from w w w .j a v a2 s . c om public static Date getTimeMax() { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String da = sdf.format(date); da = da + " 23:59:59"; Date d = getStrToDate(DATE_FORMAT_1, da); return d; } public static synchronized Date getStrToDate(String format, String str) { simpleDateFormat.applyPattern(format); ParsePosition parseposition = new ParsePosition(0); return simpleDateFormat.parse(str, parseposition); } }