Java examples for java.util:Minute
return a String from a timestamp in milliseconds format is (YEAR/MONTH/DAY,HOUR:MINUTE:SECONDS.MILLISECONDS)
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { long stamp = 2; long micros = 2; System.out.println(getTimeStringFromLongMillis(stamp, micros)); }/*from w w w . jav a 2 s. co m*/ /** * return a String from a timestamp in milliseconds * format is (YEAR/MONTH/DAY,HOUR:MINUTE:SECONDS.MILLISECONDS) * @param stamp * @param micros * @return */ public static String getTimeStringFromLongMillis(long stamp, long micros) { Calendar.getInstance().setTimeInMillis(stamp); StringBuilder sb = new StringBuilder(); sb.append("("); sb.append(Calendar.getInstance().get(Calendar.YEAR)); sb.append("/"); sb.append(Calendar.getInstance().get(Calendar.MONTH) + 1); sb.append("/"); sb.append(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); sb.append(","); sb.append(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)); sb.append(":"); sb.append(Calendar.getInstance().get(Calendar.MINUTE)); sb.append(":"); sb.append(Calendar.getInstance().get(Calendar.SECOND)); sb.append("."); sb.append(Calendar.getInstance().get(Calendar.MILLISECOND)); sb.append("."); sb.append(micros); sb.append(")"); return sb.toString(); } }