Here you can find the source of getLateInTheDay(Date date)
Parameter | Description |
---|---|
date | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date getLateInTheDay(Date date) throws ParseException
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String SHORT_DATE_FORMAT_STR = "yyyy-MM-dd"; public static final String LONG_DATE_FORMAT_STR = "yyyy-MM-dd HH:mm:ss"; public static final String LATE_TIME = "23:59:59"; /**//from w w w.j a v a 2s .c om * @param date * @return Date * @throws ParseException */ public static Date getLateInTheDay(Date date) throws ParseException { String dateString = new SimpleDateFormat(SHORT_DATE_FORMAT_STR).format(date) + " " + LATE_TIME; return new SimpleDateFormat(LONG_DATE_FORMAT_STR).parse(dateString); } /** * @param dateString * @param format * @return Date */ public static Date parse(String dateString, String format) { Date date = null; try { date = parserStringToDate(dateString, format); } catch (Exception e) { } return date; } /** * @param dateString * @param format * @return Date * @throws ParseException */ public static Date parserStringToDate(String dateString, String format) throws ParseException { DateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.parse(dateString); } }