[英]why get the wrong week display name from unix timestamp in Java
[英]Get a day from week based on Unix timestamp
Unix timestamp
为1417029117
,即1417029117
年11月26日,星期三。
long timestamp = 1417029117l*1000l;
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timestamp);
System.out.println("current day is "+cal.get(Calendar.DAY_OF_WEEK));
System.out.println("current month is "+cal.get(Calendar.MONTH));
我得到的结果如下:
current day is 4
current month is 10
有什么解释吗? 如果一月为0
则该月为好。 但是为什么今天是4
天?
一周的第一天是星期日。 因此,星期三为4。请参阅Calendar#DAY_OF_WEEK和Constant Field Values Calendar#WEDNESDAY ,它在文档中清晰可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.