Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String getWeek(String time) { return getWeek(string2Date(time, DEFAULT_PATTERN)); } public static String getWeek(String time, String pattern) { return getWeek(string2Date(time, pattern)); } public static String getWeek(Date date) { return new SimpleDateFormat("EEEE", Locale.getDefault()).format(date); } public static String getWeek(long millis) { return getWeek(new Date(millis)); } public static Date string2Date(String time) { return string2Date(time, DEFAULT_PATTERN); } public static Date string2Date(String time, String pattern) { return new Date(string2Millis(time, pattern)); } public static long string2Millis(String time) { return string2Millis(time, DEFAULT_PATTERN); } public static long string2Millis(String time, String pattern) { try { return new SimpleDateFormat(pattern, Locale.getDefault()).parse(time).getTime(); } catch (ParseException e) { e.printStackTrace(); } return -1; } }