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());
    }/*  w w  w  .  j  a  v a 2  s .co  m*/

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

Related Exercise