Java - Write code to get Current Date in yyyy-MM-dd hh:mm:ss format

Requirements

Write code to get Current Date in yyyy-MM-dd hh:mm:ss 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(getCurrentFormatDate());
    }//from  www  .  ja  v a2 s.c  om

    public static String getCurrentFormatDate() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String datetime = sdf.format(date);
        return datetime;
    }
}