Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        System.out.println("Calendar:" + cal.toString());
        Date d = cal.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("DD/MM/yyyy HH:mm:ss");
        System.out.println(sdf.format(d));
        SimpleDateFormat sdfNew = new SimpleDateFormat("HH:mm:ss");
        System.out.println(sdfNew.format(d));
    }
}