调用Java的Calendar.getTime()是否需要更新对象? [英] Is calling Java's Calendar.getTime() necessary to update the object?

查看:156
本文介绍了调用Java的Calendar.getTime()是否需要更新对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一些java代码中发现了一条注释,声明需要调用 getTime()来更新 Calendar 对象。这是真的?我找不到任何说这是必要的。

I came across a comment in some java code that states that getTime() needs to be called to update the Calendar object. Is this true? I cannot find anything that says that this is necessary.

这是代码:

Calendar cal = new GregorianCalendar();
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.set(2009, 9 - 1, 10, 2, 30);
// Get Time needs to be called to update the Calendar object
cal.getTime();


推荐答案

不,这不是真的。

这篇关于调用Java的Calendar.getTime()是否需要更新对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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