Here you can find the source of to24HrTimeString(Date date)
Parameter | Description |
---|---|
date | The Date instance. |
public static String to24HrTimeString(Date date)
//package com.java2s; /*//from w w w. j a v a2 s. c o m * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF * Institute of Systems Science, National University of Singapore * * Copyright 2012 Team 4(Part-Time), ISS, NUS, Singapore. All rights reserved. * Use of this source code is subjected to the terms of the applicable license * agreement. * * ----------------------------------------------------------------- * REVISION HISTORY * ----------------------------------------------------------------- * DATE AUTHOR REVISION DESCRIPTION * 10 March 2012 Chen Changfeng 0.1 Class creating * * * * * */ import java.text.SimpleDateFormat; import java.util.*; public class Main { private static String time24HrFormat = "HH:mm"; /** * Return the formatted string of the given date instance based on * the 24 hour format specified for time in the System property. * <p> * If the properties file is not available or the timeformat property has * not been specified, the default format "HH:mm" will be used. * <p> * @param date The Date instance. * @return The Time String from the date instance in 24 hour format. */ public static String to24HrTimeString(Date date) { if (date == null) return null; String timeformat = null; // Use the default format of "hh:mm aa". timeformat = time24HrFormat; return format(date, timeformat); } /** * Get the formatted string of the given date instance based on the * date format provided. * <p> * @param date The date that needs to be formatted. * @param format The format to be applied to the date. * @return The formatted Date String. */ public static String format(Date date, String format) { if (date == null || format == null) return null; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }