Java examples for java.util:Week
end Day Of Week
/****************************************************************************** * Copyright (C) 2012 ShenZhen 1000funs Information Technology Co.,Ltd * All Rights Reserved.//from w w w .ja v a 2s .c o m * ??????????????????????? *****************************************************************************/ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Vector; public class Main{ public final static String ISO_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public final static String ISO_DATE_FORMAT = "yyyy-MM-dd"; public static String endDayOfWeek(int year, int week) { Calendar objCalendar = Calendar.getInstance(); objCalendar.set(Calendar.YEAR, year); objCalendar.set(Calendar.WEEK_OF_YEAR, week); // ??Calendar.setFirstDayOfWeek() objCalendar.add(Calendar.DAY_OF_WEEK, (-1 * objCalendar.get(Calendar.DAY_OF_WEEK)) + 2 + 6); return formatDate(objCalendar.getTime()); } public static String formatDate(Date value) { return formatDateTime(value, ISO_DATE_FORMAT); } public static String formatDateTime(Date value) { return formatDateTime(value, ISO_DATETIME_FORMAT); } public static String formatDateTime(Date value, String defaultFormat) { if (value == null) { return ""; } String strFormatStyle = StringUtil.isEmpty(defaultFormat) ? ISO_DATETIME_FORMAT : defaultFormat; SimpleDateFormat objSimpleDateFormat = new SimpleDateFormat( strFormatStyle); return objSimpleDateFormat.format(value); } }