摘自:http://www.blogjava.net/wangxinsh55/archive/2006/12/08/86303.html
方法一、
public static String getFullDateWeekTime(String sDate){
try{
String formater = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat format = new SimpleDateFormat(formater);
Date date=format.parse(sDate);
format.applyPattern("yyyy-MM-dd E HH:mm:ss");
return format.format(date);
}catch(Exception ex){
System.out.println("TimeUtil getFullDateWeekTime"+ex.getMessage());
return "";
}
}
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Test {
public static void main(String[] args) {
final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五",
"星期六" };
String s = "2006-01-12 16:30";
SimpleDateFormat sdfInput = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Calendar calendar = Calendar.getInstance();
Date date = new Date();
try {
date = sdfInput.parse(s);
} catch (ParseException e) {
e.printStackTrace();
}
calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK)-1;
if(dayOfWeek<0)dayOfWeek=0;
System.out.println(dayNames[dayOfWeek]);
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/778728/viewspace-967576/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/778728/viewspace-967576/