user9709261 :
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, YYYY, EEE", Locale.US);
System.out.println(sdf.format(new Date()));
System.out.println(sdf.format(sdf.parse("Apr 27, 2018, Fri")));
Java does not parse the date as expected and outputs:
Apr 27, 2018, Fri
Jan 05, 2018, Fri // I can not understand why java parse the month of April as January
achAmháin :
Your problem is that you are using YYYY
, which represents Week year
, whereas you wanted yyyy
which represents year
, see all options here.
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy, EEE", Locale.US);
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=464617&siteId=1