为什么Java日历报告的日期不正确? [英] Why is Java Calendar reporting the incorrect date?

查看:141
本文介绍了为什么Java日历报告的日期不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我为什么当它是今天第22天(英国)时在控制台中显示'5'?!

Could anyone let me know why the following is displaying '5' in the console when it is the 22nd today (UK)?!

System.out.println(Calendar.DAY_OF_MONTH);

提前感谢!

推荐答案

Calendar.DAY_OF_MONTH 只是用于各种操作的常数(并且恰好其值为 5 ),您应该使用:

Calendar.DAY_OF_MONTH is just a constant used for various operations (and happens to be its value is 5), you should be using:

Calender.getInstance().get(Calendar.DAY_OF_MONTH);

这篇关于为什么Java日历报告的日期不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆