通过Calendar类判断是否是周末及是否在指定时间

package time;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;

public class Weekday {
	public static void main(String[] args) {
		//long time=System.currentTimeMillis();
		Date date=new Date();
		long time=date.getTime();
		Timestamp ts=new Timestamp(time);
		System.out.println(ts);
		int zone=ts.getHours();
		System.out.println(zone);
		if(zone>=8&&zone<=18){
			System.out.println("xxxx");
		}else{
			System.out.println("oooo");
		}
		Calendar cal=Calendar.getInstance();
		cal.setTime(date);
		if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
			System.out.println("oooo");
		}else{
			System.out.println("xxxx");
		}
	}

}

  

上一篇:load data ERROR 1197 (HY000)错误


下一篇:IOS ARC和非ARC文件混用