Java Date format to String as 12:20

Description

Java Date format to String as 12:20


import java.text.SimpleDateFormat;
import java.util.Date;

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

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



PreviousNext

Related