首页IT科技java设置按钮不可见(java Android get date before 7 days (one week) Stack Overflow)

java设置按钮不可见(java Android get date before 7 days (one week) Stack Overflow)

时间2025-06-20 23:10:47分类IT科技浏览5005
导读:Parse the date: Date...

Parse the date:

Date myDate = dateFormat.parse(dateString);

And then either figure out how many milliseconds you need to subtract:

Date newDate =newDate(myDate.getTime()-604800000L);// 7 * 24 * 60 * 60 * 1000

Or use the API provided by the java.util.Calendar class:

Calendar calendar =Calendar.getInstance(); calendar.setTime(myDate); calendar.add(Calendar.DAY_OF_YEAR,-7);Date newDate = calendar.getTime();

Then, if you need to, convert it back to a String:

String date = dateFormat.format(newDate);

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
vue底部导航栏点击切换样式(Vue自定义部分页面显示导航栏功能)