package com.ticket.filter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Time {
public static int dayForWeek(String pTime) throws Exception {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(format.parse(pTime));
int dayForWeek = 0;
if(c.get(Calendar.DAY_OF_WEEK) == 1){
dayForWeek = 7;
}else{
dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
}
System.out.print( dayForWeek);
return dayForWeek;
}
public static void main(String[] args) throws ParseException{
try {
dayForWeek("2013-12-23");
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}