Here you can find the source of getStartEndOFWeek(int enterWeek, int enterYear)
Parameter | Description |
---|---|
enterWeek | Number of the week in the year |
enterYear | year |
public static String getStartEndOFWeek(int enterWeek, int enterYear)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**//from ww w . j a v a 2 s .c om * Return the date of start and end of the week * @param enterWeek Number of the week in the year * @param enterYear year * @return Return string in format "yyyy.mm.dd - yyyy.mm.dd" */ public static String getStartEndOFWeek(int enterWeek, int enterYear) { Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.WEEK_OF_YEAR, enterWeek); calendar.set(Calendar.YEAR, enterYear); SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); // PST` Date startDate = calendar.getTime(); String startDateInStr = formatter.format(startDate); calendar.add(Calendar.DATE, 6); Date enddate = calendar.getTime(); String endDaString = formatter.format(enddate); return startDateInStr + " - " + endDaString; } }