Java tutorial
//package com.java2s; //License from project: Apache License import android.annotation.SuppressLint; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getHMS(long timestamp) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); String time = null; try { return sdf.format(new Date(timestamp)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return time; } @SuppressLint("SimpleDateFormat") public static String getHMS(String time) { long timestamp = Long.parseLong(time); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); try { String str = sdf.format(new Timestamp(timestamp)); return str; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return time; } }