Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) throws Exception {
        String someDate = "22/03/2015";
        SimpleDateFormat strToDate = new SimpleDateFormat("dd/MM/yyyy");
        Date currentDate = strToDate.parse(someDate);
        System.out.println("Date is :  " + currentDate);

        String dateFormat = "yyyy-MM-dd HH:mm:ss.SSS";
        SimpleDateFormat dateToStr = new SimpleDateFormat(dateFormat);
        String formattedDate = dateToStr.format(currentDate);
        System.out.println("Formated Date is : " + formattedDate);

    }
}