Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static void main(String[] args) throws Exception {
        String inputText = "Nov 10,2015";

        TimeZone utc = TimeZone.getTimeZone("UTC");

        SimpleDateFormat inputFormat = new SimpleDateFormat("MMM d,yyyy", Locale.US);
        inputFormat.setTimeZone(utc);

        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
        outputFormat.setTimeZone(utc);

        Date parsed = inputFormat.parse(inputText);
        String outputText = outputFormat.format(parsed);

        System.out.println(outputText);
    }
}