Here you can find the source of formateTime(long milliseconds)
public static String formateTime(long milliseconds)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { public final static String TIMEFORMAT_WITHOUT_SECONDS = "yyyy/M/d HH:mm"; public static String formateTime(long milliseconds) { SimpleDateFormat formatter = new SimpleDateFormat(TIMEFORMAT_WITHOUT_SECONDS); Date date = new Date(milliseconds); formatter.setTimeZone(TimeZone.getTimeZone("GMT+8")); return formatter.format(date); }//from w w w .j a va2s . c o m public static String formateTime(long milliseconds, String timeFormat) { SimpleDateFormat formatter = new SimpleDateFormat(timeFormat); Date date = new Date(milliseconds); formatter.setTimeZone(TimeZone.getTimeZone("GMT+8")); String time = formatter.format(date); return time; } }