I need to parse a string that initially does not have a set year of "August 13 11:30"
but when I give out the date on which the year is added, I tried the given year, but the year is completely wrong, the output goes like "Thu Aug 13 11:30:00 GMT 3911"
Is there any way to set the year after parsing the date?
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM HH:mm"); String dateStr = "13 Aug 11:30"; Date fromDate = (Date)formatter.parse(dateStr); fromDate.setYear(2011);
source share