Android examples for java.util:Week
get number of Week in Year
import android.text.TextUtils; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; public class Main{ public static int getWeekOfYear() { return getWeekOfYear(new Date()); }/*from ww w . j a v a2s . c o m*/ public static int getWeekOfYear(Date date) { Calendar c = Calendar.getInstance(); c.setFirstDayOfWeek(Calendar.MONDAY); c.setTime(date); int week = c.get(Calendar.WEEK_OF_YEAR) - 1; week = week == 0 ? 52 : week; return week > 0 ? week : 1; } }