我想在我的应用程序中使用current time。
然后,我想将30 minutes添加到当前时间。
实现这一目标的最佳实践是什么?
我能够从我的web服务中获取启动和停止时间。例如:((开始时间)上午11:00到(停止时间)晚上11:00)现在,我想将30 minutes加到当前时间,直到到达停止时间。
发布于 2012-03-20 18:05:03
Calendar now = Calendar.getInstance();
now.add(Calendar.MINUTE, 30);并输出您可以使用的时间
// 24 hours format
SimpleDateFormat df = new SimpleDateFormat("HH:mm");
// AM/PM format
SimpleDateFormat df = new SimpleDateFormat("hh:mm aa");
System.out.println(df.format(now.getTime()));发布于 2012-03-20 18:06:29
使用以下内容:
//get current Time
long currentTime = System.currentTimeMillis();
//now add half an hour, 1 800 000 miliseconds = 30 minutes
long halfAnHourLater = currentTime + 1800000;发布于 2012-03-20 18:05:47
System.currentTimeMillis()+(30*60*1000);https://stackoverflow.com/questions/9784614
复制相似问题