I'm not sure what's wrong with my code. When I run it the output is always set to January regardless of what input date is entered. Your help is appreciated.
package com.codegym.task.task09.task0922;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/*
What's today's date?
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
String sDate = read.readLine();
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-mm-dd");
System.out.println(sDate);
SimpleDateFormat targetFormat = new SimpleDateFormat("MMM dd, yyyy");
Date date = originalFormat.parse(sDate);
String formattedDate = targetFormat.format(date); // 20120821
System.out.println(formattedDate);
}
}