Here you can find the source of dateToTimeString(Date date)
Parameter | Description |
---|---|
date | the specified date to convert |
public static String dateToTimeString(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// w w w . ja v a 2 s. c o m * return time value only of specified date in format: HH:mm:ss * * @param date the specified date to convert * @return String value */ public static String dateToTimeString(Date date) { return dateToStringWithPattern(date, "HH:mm:ss"); } /** * return time value of specified date * * @param date the specified date to convert * @param pattern time format * @return String value */ public static String dateToStringWithPattern(Date date, String pattern) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(date); } catch (Exception e) { return ""; } } }