我想改变android日历时间。 这是我的代码:
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 10);
c.set(Calendar.MINUTE, 10);
c.set(Calendar.SECOND, 10);
......其他代码和方法
System.out.println("h : " + Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
System.out.println("m :" + Calendar.getInstance().get(Calendar.MINUTE));
System.out.println("s :" + Calendar.getInstance().get(Calendar.SECOND));
但没有发生变化
get方法返回默认仿真时间
能帮助我一个人吗? 谢谢!
答案 0 :(得分:5)
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 10);
c.set(Calendar.MINUTE, 10);
c.set(Calendar.SECOND, 10);
System.out.println("h : " + c.get(Calendar.HOUR_OF_DAY));
System.out.println("m :" + c.get(Calendar.MINUTE));
System.out.println("s :" + c.get(Calendar.SECOND));