get Pretty Time - Java java.util

Java examples for java.util:Date Format

Description

get Pretty Time

Demo Code


//package com.java2s;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        int hour = 2;
        int minute = 2;
        System.out.println(getPrettyTime(hour, minute));
    }//from  ww  w  . ja  v  a2s . co m

    public static String getPrettyTime(int hour, int minute) {
        Calendar c = new GregorianCalendar(0, 0, 0, hour, minute);
        DateFormat timeFormat = DateFormat
                .getTimeInstance(DateFormat.SHORT);
        return timeFormat.format(c.getTime());
    }
}

Related Tutorials