您的位置:首页 > 编程语言 > Java开发

JAVA求前一天的日期

2016-02-24 19:42 453 查看
Calendar calendar = Calendar.getInstance();
// 获得日历对象
calendar.setTime(new Date());
// 先设置为当前时间
calendar.add(Calendar.DAY_OF_YEAR, -1);
// 再次设置日历时间
Date bf = new Date();
bf = calendar.getTime();
// 新的日期对象并获取日历的时间
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
// 设置时间的格式
String s = format.format(bf);
//转换为字符串格式


在数据分析方面能起到举足轻重的作用!!

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: