java date.getdate_java – 获取昨天 – 不推荐使用Date类型的方法getDate()

Date#getDate()是JDK 1.1之后的弃用方法.您应该使用

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值