android - how to get week of the year using input date from user -


how current week of year using date? below code returns current week of year using current time. how change code take input date 26/8/2013?(in caseit should return 35). want implement taking input date form user return current week of year.

calendar calender = calendar.getinstance(); log.d("current week:", "" + calender.get(calendar.week_of_year)); toast.maketext(this, "current year weeks is"+ calender.get(calendar.week_of_year),    toast.length_short).show(); 

import java.text.simpledateformat; import java.util.calendar; import java.util.date; import java.util.gregoriancalendar; import android.net.parseexception; import android.widget.toast;  ...  /** * @param userinput input date user, format: "26/8/2013" */ public void getdayofweek(string userinput) {     date date;     simpledateformat format = new simpledateformat("dd/m/yyyy");       try {           date = format.parse(userinput);     } catch (parseexception e) {           e.printstacktrace();       }      calendar calender = new gregoriancalendar();     calender.settime(date);     toast.maketext(this, "current year weeks is" + calender.get(calendar.week_of_year), toast.length_short).show();  } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -