java date.getdate_java – 获取昨天 – 不推荐使用Date类型的方法getDate()
Date#getDate()是JDK 1.1之后的棄用方法.您應(yīng)該使用
Calendar類來操縱日期.
Prior to JDK 1.1, the class Date had two additional functions. It
allowed the interpretation of dates as year, month, day, hour, minute,
and second values. It also allowed the formatting and parsing of date
strings. Unfortunately, the API for these functions was not amenable
to internationalization. As of JDK 1.1, the Calendar class should be
used to convert between dates and time fields and the DateFormat class
should be used to format and parse date strings. The corresponding
methods in Date are deprecated.
在使用Date#getDate()的API中也清楚地記錄了使用Calendar#get(Calendar.DATE);
Deprecated. As of JDK version 1.1, replaced by
Calendar.get(Calendar.DAY_OF_MONTH)
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
return dateFormat.format(cal.getTime());
總結(jié)
以上是生活随笔為你收集整理的java date.getdate_java – 获取昨天 – 不推荐使用Date类型的方法getDate()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高校软件测试实验室建设误区
- 下一篇: 基本统计分析方法