Java - Write code to format Timestamp in long value to string in mm:ss format

Requirements

Write code to format Timestamp in long value to string in mm:ss format

Demo

//package com.book2s;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

public class Main {
    public static void main(String[] argv) {
        long time = 23412342;
        System.out.println(simpleTimeStr(time));
    }/* w ww. j  a  v a 2s .  c o  m*/

    private static SimpleDateFormat simpleTimeFormate = new SimpleDateFormat(
            "mm:ss");

    public static String simpleTimeStr(long time) {
        if (time > 0) {
            return simpleTimeFormate.format(new Timestamp(time));
        } else {
            return "--";
        }
    }
}

Related Exercise