I am trying to get this date 09/03/18 6:30:00 PM using 4-SEP-2018 but I am getting 12/364/17 6:30:00 PM, Here is what I have tried.
public class StockBuySell
{
static String DATE_FORMAT_UI = "DD-MMM-YYYY";
public static void main(String args[]) throws Exception {
DateFormat outputFormat = new SimpleDateFormat("MM/DD/YY h:mm:ss a");
outputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
DateFormat inputFormat = new SimpleDateFormat(DATE_FORMAT_UI);
String inputText = "4-SEP-2018";
Date date = inputFormat.parse(inputText);
String outputText = outputFormat.format(date);
System.out.println(outputText);
}
}