欢迎光临
我们一直在努力

取时间的小类-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

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()

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 取时间的小类-JSP教程,Java技巧及代码
分享到: 更多 (0)

相关推荐

  • 暂无文章