Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import android.text.format.Time; public class Main { public static String GetCurrentFormatTime(String format) { Time time = new Time(); time.setToNow(); return GetCurrentFormatTime(time.toMillis(false), format); } public static String GetCurrentFormatTime(Long longTime, String format) { if (longTime > 0) { return new SimpleDateFormat(format).format(longTime); } else { return ""; } } }