做的是个彩票的倒计时 每天早上10:20开盘,每周的2 5 7 晚上20:20停盘 在10:20--20:20时间段显示的是停盘时间 其他时间是显示开盘时间
public class TimeCountDownService {
private SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public String getTime() throws ParseException {
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
String houStr = (hour >= 10) ? hour + "" : "0" + hour;
String minStr = (minute >= 10) ? minute + "" : "0" + minute;
String temp = houStr + ":" + minStr;
int week = calendar.get(Calendar.DAY_OF_WEEK);
if ((temp.compareTo("10:20")) <= 0&&(temp.compareTo("20:20"))>0) {//50400
if(temp.compareTo("20:20")>0&&te