java - Calendar week_of_year comes week_of_month -


i retrieving number of week in year date seems returns me number of week in month.

    calendar cal = calendar.getinstance();     try {         cal.settime((new simpledateformat("yyyy-mm-dd")).parse(date));     } catch (parseexception e) {         // todo auto-generated catch block         e.printstacktrace();     }     int num_of_week = cal.get(calendar.week_of_year); 

i input "2014-08-18" , comes out 3 result.......how can correctly retrieve week number.......

try this:

cal.settime((new simpledateformat("yyyy-mm-dd")).parse(date));                                         ^^---change month mm 

instead of

cal.settime((new simpledateformat("yyyy-mm-dd")).parse(date)); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -