Here you can find the source of getHourMin(Date date)
public static String getHourMin(Date date)
//package com.java2s; /**/*from w w w . j a v a 2 s. co m*/ * Copyright © 2012-2013 <a href="https://github.com/sccl/attech">attech</a> All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); */ import java.util.Calendar; import java.util.Date; public class Main { public static String getHourMin(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); String ohHour = cal.get(Calendar.HOUR_OF_DAY) + ""; String ohMinute = cal.get(Calendar.MINUTE) + ""; if (ohMinute.length() == 1) { ohMinute = "0" + ohMinute; } if (ohHour.length() == 1) { ohHour = "0" + ohHour; } String ohTime = ohHour + ":" + ohMinute; return ohTime; } }