Can someone explain why I get these values ββwhen trying to parse a date? I tried three different inputs:
1) Third week of 2013
Date date = new SimpleDateFormat("ww.yyyy").parse("02.2013"); Calendar cal = Calendar.getInstance(); cal.setTime(date); System.out.println(cal.get(Calendar.WEEK_OF_YEAR) + "." + cal.get(Calendar.YEAR));
What outputs: 02.2013 (as I expected)
2) First week of 2013
Date date = new SimpleDateFormat("ww.yyyy").parse("00.2013"); Calendar cal = Calendar.getInstance(); cal.setTime(date); System.out.println(cal.get(Calendar.WEEK_OF_YEAR) + "." + cal.get(Calendar.YEAR));
What outputs: 52.2012 (which is suitable for me, since the first week of 2013 is also the last of 2012)
3) Second week of 2013
Date date = new SimpleDateFormat("ww.yyyy").parse("01.2013"); Calendar cal = Calendar.getInstance(); cal.setTime(date); System.out.println(cal.get(Calendar.WEEK_OF_YEAR) + "." + cal.get(Calendar.YEAR));
What outputs: 1.2012 (which does absolutely nothing for me)
Does anyone know why this is happening? I need to parse the date in the format (week of the year). (Year). Am I using the wrong template?
java parsing simpledateformat
fvdalcin
source share