package pub.dates;
import java.text.dateformat;
import java.util.*;
public class dates
{
date param=null;
calendar ca=calendar.getinstance();
public dates()
{
param=new date();
ca.settime(param);
}
public dates(date vars)
{
param=vars;
ca.settime(param);
}
public dates(int y,int m,int d)
{
y=y-1900;m=m-1;
param=new date(y,m,d);
ca.settime(param);
}
//
public int getyear()
{
return ca.get(calendar.year);
}
public int getmonth()
{
return 1+ca.get(calendar.month);
}
public int getday()
{
return ca.get(calendar.day_of_month);
}
public int gethour()
{
return ca.get(calendar.hour_of_day);
}
public int getminute()
{
return ca.get(calendar.minute);
}
public int getsecond()
{
return ca.get(calendar.second);
}
public string getdate()
{
return getyear()+"-"+getmonth()+"-"+getday();
}
public string gettime()
{
return gethour() + ":" + getminute() + ":" + getsecond();
}
}
//package部分自己随意.
构造方法:(3个)
dates();
dates(date date);
dates(int y,int m, int d); y,m,d是年.月.日
方法:
getyear(); getmonth(); getday(); gethour(); getminute(); getsecond(); getdate(); gettime()
