Java - Write code to get Now Time in hh:mm format

Requirements

Write code to get Now Time in hh:mm format

Demo

//package com.book2s;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static void main(String[] argv) {
        System.out.println(getNowTime());
    }/*from  w w w . j  av a2  s . c  o m*/

    public static String getNowTime() {
        SimpleDateFormat format = new SimpleDateFormat("hh:mm");
        return format.format(new Date());
    }
}

Related Exercise