Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) {
        String text = "09/19/2014";
        // Create a pattern for the date text "09/19/2014"
        String pattern = "MM/dd/yyyy";
        SimpleDateFormat simpleFormatter = new SimpleDateFormat(pattern);
        // a ParsePosition object with value zero
        ParsePosition startPos = new ParsePosition(0);
        // Parse the text
        Date parsedDate = simpleFormatter.parse(text, startPos);

        System.out.println(parsedDate);
    }

}