Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.NumberFormat;

import java.util.Calendar;

public class Main {
    public final static String TIME_NONE = "none";

    public static String getTimeFromLong(long l) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(l);

        Calendar t = Calendar.getInstance();
        t.set(Calendar.HOUR_OF_DAY, 0);
        t.set(Calendar.MINUTE, 1);
        t.set(Calendar.SECOND, 0);

        if (c.after(t)) {
            NumberFormat nf = NumberFormat.getInstance();
            nf.setMinimumIntegerDigits(2);

            return nf.format(c.get(Calendar.HOUR_OF_DAY)) + ":" + nf.format(c.get(Calendar.MINUTE));
        } else {
            return TIME_NONE;
        }
    }
}