Java - Write code to convert Current Time to String in HH:mm format

Requirements

Write code to convert Current Time to String in HH:mm format

Demo

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

public class Main {
    public static void main(String[] argv) {
        System.out.println(stringForCurrentTime());
    }/*from  ww w. j  a va  2s . c o  m*/

    public static String stringForCurrentTime() {
        return new SimpleDateFormat("HH:mm").format(Calendar.getInstance()
                .getTime());
    }
}

Related Exercise