?? checdateandtime.java
字號:
package checdateapi;public class CHECDateAndTime { public final static int FLAG_SECOND=1; public final static int FLAG_MINUTE=2; public final static int FLAG_HOUR=3;public final static int FLAG_MICROSECOND=0;public final static int FLAG_YEAR=6; public final static int FLAG_MONTH=5; public final static int FLAG_DAY=4; CHECDate date=new CHECDate(); CHECTime time=new CHECTime(); public CHECDateAndTime() { date.setDate(1970,1,1); time.setTime(0,0,0); } public CHECDateAndTime(int y,int m,int d) { date.setDate(y,m,d); } public CHECDateAndTime(CHECDate cd) { date.setDate(cd); } public CHECDateAndTime(int y,int m,int d ,int h,int mm,int s) { date.setDate(y,m,d); time.setTime(h,mm,s); } public CHECDateAndTime(CHECDate cd,CHECTime ct) { date.setDate(cd); time.setTime(ct); } public CHECDateAndTime(int y,int m,int d ,int h,int mm,int s,int ms) { date.setDate(y,m,d); time.setTime(h,mm,s); time.setMicroSecond(ms); } public CHECDateAndTime(String time) { setDate(time); } public CHECDateAndTime(CHECDateAndTime cdat) { date.setDate(cdat.getDate()); time.setTime(cdat.getTime()); } public void setDate(CHECDate cd){ date.setDate(cd); } public void setDate(CHECDate cd,CHECTime ct){ date.setDate(cd); time.setTime(ct); } public CHECDate getDate(){ return date; } public void setDate(int y,int m,int d){ date.setDate(y,m,d); } public void setTime(int h,int mm,int s){ time.setTime(h,mm,s); } public void setTime(int h,int mm,int s,int ms){ //time.setTime(h,mm,s); time.setTime(h,mm,s,ms); } public void setTime(CHECTime ct){ time.setTime(ct); } public CHECTime getTime(){ return time; } public void setDate(CHECDateAndTime cdat){ date.setDate(cdat.getDate()); time.setTime(cdat.getTime()); } public void setYear(int y){ date.setYear(y); } public int getYear(){ return date.getYear(); } public void setMonth(int m){ date.setMonth(m); } public int getMonth(){ return date.getMonth(); } public void setDay(int d){ date.setDay(d); } public int getDay(){ return date.getDay(); } public void setHour(int h){ time.setHour(h); } public int getHour(){ return time.getHour(); } public void setMinute(int m){ time.setMinute(m); } public int getMinute(){ return time.getMinute(); } public void setSecond(int s){ time.setSecond(s); } public int getSecond(){ return time.getSecond(); } public void setMicroSecond(int ms){ time.setMicroSecond(ms); } public int getMicroSecond(){ return time.getMicroSecond(); } public boolean equal(CHECDateAndTime cdat){ boolean b=false; if(date.equal(cdat.getDate() )&& time.equal(cdat.getTime()) ) { b=true; } return b;} public String toString(){ String rtString; rtString =date.toString()+" "+ time.toString(); return rtString; }public String toStringMicroSecond(){ String rtString; rtString =date.toString()+" "+ time.toStringMicroSecond(); return rtString;} public void setDate(String str){ String strDate,strTime; str.trim(); int index=str.indexOf(" "); if(index>8) { strDate=str.substring(0,index); strTime=str.substring(index+1,str.length()); } else { strDate=str; strTime=" "; } date.setDate(strDate); time.setTime(strTime);}public CHECDateAndTime nextDay(){ CHECDateAndTime rcdat=new CHECDateAndTime(date.nextDay(),time); return rcdat;}public CHECDateAndTime beforeDay(){ CHECDateAndTime rcdat=new CHECDateAndTime(date.beforeDay(),time); return rcdat;}public boolean upper(CHECDateAndTime t){ if(date.dateUpper(t.getDate())) {return true;} else if( date.equal( t.getDate()) & time.timeUpper(t.getTime())) {return true;} return false;} public boolean lower(CHECDateAndTime t){ if(date.dateLower(t.getDate())) {return true;} else if ( date.equal(t.getDate()) & time.timeLower(t.getTime())) {return true;} return false; }public boolean lowerEqual(CHECDateAndTime t){ if(date.dateLower(t.getDate())) {return true;} else if ( date.equal(t.getDate()) & time.timeLowerEqual(t.getTime())) {return true;} return false; }public boolean upperEqual(CHECDateAndTime t){ if(date.dateUpper(t.getDate())) {return true;} else if ( date.equal(t.getDate()) & time.timeUpperEqual(t.getTime())) {return true;} return false;}public CHECDateAndTime add(long s){ CHECTime t=new CHECTime(); CHECDate d=new CHECDate(); t.setTime(time); d.setDate(date); long ds=t.add(s); d=d.add(ds); CHECDateAndTime rd=new CHECDateAndTime(d,t); return rd;}public CHECDateAndTime addMicroSecond(long s){ CHECTime t=new CHECTime(); CHECDate d=new CHECDate(); t.setTime(time); d.setDate(date); long ds=t.addMicroSecond(s); d=d.add(ds); CHECDateAndTime rd=new CHECDateAndTime(d,t); return rd;}public CHECDateAndTime add(int flag,long d){ CHECDateAndTime rtd=new CHECDateAndTime(date,time); CHECDate tmpd=rtd.getDate(); CHECTime tmpt=rtd.getTime(); long ds=tmpt.add(flag,d); tmpd=tmpd.add(ds); tmpd.setDate(tmpd.add(flag,d)); rtd.setDate(tmpd); rtd.setTime(tmpt); return rtd;}public long diff(CHECDateAndTime dt){ CHECTime t=new CHECTime(); CHECDate d=new CHECDate(); t.setTime(time); d.setDate(date); return d.diffDate(dt.getDate())*86400+t.diffTime(dt.getTime());}public int getMaxDays() { return date.getMaxDays(); }public int getMaxDays(int yyyy,int mm) {return date.getMaxDays(yyyy,mm); }public long getStamp(){ return date.getStamp()*100000+time.getStamp();}public boolean isInitTime(){ boolean b=false; if((date.getYear()==1970) && (date.getMonth()==1) && (date.getDay()==1) && (time.getHour()==0) &&(time.getMinute()==0)&& (time.getSecond()==0)&& (time.getMicroSecond()==0)){b=true;}return b;}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -