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  ww  . j  a  va  2s .  c  om

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

Related Exercise