Here you can find the source of printTime(Date date)
public static String printTime(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String printTime(Date date) { if (date == null) return null; DateFormat formatter = new SimpleDateFormat("HH:mm:ss"); DateFormat tzFormatter = new SimpleDateFormat("Z"); String timezone = tzFormatter.format(date); return formatter.format(date) + timezone.substring(0, 3) + ":" + timezone.substring(3); }// ww w. j av a 2s. c om }