java如何在某一天之前到达
我想为某个特定的日期缩短一天。但在一个月内会减少
df = new SimpleDateFormat("EEEE, dd MMMM YYYY");
Date prevDate = df.parse(dateText.getText().toString());
Calendar c = Calendar.getInstance();
c.setTime(prevDate);
c.add(Calendar.DATE, -1);
Date d=c.getTime();
dateText.setText(df.format(d));
# 1 楼答案
java.time.LocalDate
您可以使用^{} 如下所示
最好避免
Date
类。但如果必须的话,你可以皈依打印结果
# 2 楼答案
如果坚持使用日历,请尝试以下操作:
但你也会使用毫秒。 在这种情况下,也许以下几点就足够了:
最好的方法是使用JodaTime:
我会使用JodaTime,尤其是如果你的应用程序中有更多的日期/时间操作