Here you can find the source of getPreWeekDayByStr(String curday)
public static String getPreWeekDayByStr(String curday)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); public static String getPreWeekDayByStr(String curday) { try {//from w w w . j a va 2s . c o m java.util.Date date = str2utilDate(curday); Calendar rightNow = Calendar.getInstance(); rightNow.setTime(date); int week = rightNow.get(Calendar.DAY_OF_WEEK); if (week == 0) week = 1; if (week == 7) week = 8; return getDateStr(new java.util.Date(date.getTime() - week * 24 * 3600 * 1000)); } catch (Exception e) { System.out.println("DateUtil.getYearWeek(str) Error:e = " + e); return ""; } } public static java.util.Date str2utilDate(String str) { try { java.util.Date udate = yyyyMMdd.parse(str); return udate; } catch (Exception e) { System.out.println("DateUtil.str2utilDate(str) Error:e = " + e); return null; } } public static String getDateStr(java.util.Date date) { if (date == null) return ""; try { return yyyyMMdd.format(date); } catch (Exception e) { return ""; } } }