Here you can find the source of getFirstDayOfWeek(String week)
public static String getFirstDayOfWeek(String week)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String LEGACY_FORMAT = "MM/dd/yyyy HH:mm aa"; public static String getFirstDayOfWeek(String week) { try {// w w w. ja va 2 s. c o m return getDefaultDateFormat().format(getDefaultWeekFormat().parse(week)); } catch (ParseException e) { return "ERROR_DAY"; } } public static String format(Date date, String formatPattern) { if (date == null) { return ""; } else { return new SimpleDateFormat(formatPattern).format(date); } } public static SimpleDateFormat getDefaultDateFormat() { return new SimpleDateFormat("yyyyMMdd"); } public static Date parse(String s, String formatPattern) { try { return new SimpleDateFormat(formatPattern).parse(s); } catch (ParseException e) { throw new RuntimeException("could not parse date: " + s + " LEGACY_FORMAT = " + new SimpleDateFormat(LEGACY_FORMAT).toPattern(), e); } } public static SimpleDateFormat getDefaultWeekFormat() { return new SimpleDateFormat("yyyyww"); } }