I am trying to parse String date to a particular date format, but when I used options available from SimpleDateFormat
I always get different result. This is the string i am trying to parse:
String datetToParse = ""2019-07-04 00:32:08:627158"" into 04-JUL-19 12.32.08.627158000 AM.
Can i achieve this using simpledateformat or any other date formatter? Any help will be highly appreciated.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormat {
public static void main(String[] args) {
String date = "2019-07-04 00:32:08:627158";
SimpleDateFormat sf = new SimpleDateFormat("yymmdd");
Date d = null;
try {
d= sf.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(d);
}
}