为了账号安全,请及时绑定邮箱和手机立即绑定

添加或子日历

添加或子日历

偶然的你 2023-08-09 15:34:26
我可以通过使用像日期 5-6-2018 到 26-9-2018 这样的参数来使用日历吗?我正在寻找很多解决方案,但我没有得到,我需要帮助完成我的作业不在乎 31 天或 30 天或闰年,只是我需要如何做public Date(int day, int month, int year) {  this.day = day;  this.month=month;  this.year=year;}public void setDay(int day) {        this.day = day;    }    public void setmonth(int month) {        this.month = month;  }    public void setYear(int year) {        this.year = year;      } public int getDay() {        return day;    }    public int getMonth() {        return month;    }    public int getYear() {        return year;    }
查看完整描述

1 回答

?
子衿沉夜

TA贡献1828条经验 获得超3个赞

最后我很容易地解决了T_T,我花了两周的时间来解决


 public Date1(int d, int m, int y) {


        this.day = d;

        this.month = m;

        this.year = y;

    }




  public void addDay() {

    month--;

    Calendar m = Calendar.getInstance();

    m.set(year, month, day);

    m.add(day, 5);


    java.sql.Date d = new java.sql.Date(m.getTimeInMillis());

    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

    System.out.println(" date is  " + df.format(d));


}


查看完整回答
反对 回复 2023-08-09
  • 1 回答
  • 0 关注
  • 69 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信