Here you can find the source of getTimeRangeStr(Date startDate, Date endDate)
Parameter | Description |
---|---|
startDate | range start |
endDate | range end |
public static String getTimeRangeStr(Date startDate, Date endDate)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { final static DateFormat HOUR_DATE_FORMAT = new SimpleDateFormat("HH:mm"); /**// ww w . j a v a 2s . c o m * Returns "22:00 - 23:00" for params "2014-02-09 22:00" and "2017-12-31 23:00" * * @param startDate range start * @param endDate range end * @return range str */ public static String getTimeRangeStr(Date startDate, Date endDate) { return getTimeStr(startDate) + " - " + getTimeStr(endDate); } /** * Returns "22:00" for param "2014-02-09 22:00" * * @param date the datetime * @return time str */ public static String getTimeStr(Date date) { return HOUR_DATE_FORMAT.format(date); } }