如何为时间戳添加时间? [英] How do I add time to a timestamp?

查看:687
本文介绍了如何为时间戳添加时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在数组中的未知时间增加14分59秒。我该怎么做呢?这是我到目前为止的内容:

I need to add 14 minutes and 59 seconds to an unknown time in an array. How do I do this? This is what I have so far:

Date duration = df.parse("0000-00-00 00:14:59");

arrayOpportunity[2] = arrayOpportunity[2] + duration;

时间没有改变。谢谢!

我已经完成了研究。我无法粘贴完整的代码。但主要是我不想让您阅读所有内容。只是寻找有关如何添加两个时间戳的简单答案。

I have done my research. I cant paste the entire code I have. But mainly I didnt want to make you read it all. Just looking for a simple answer of how to add two timestamps.

推荐答案

如果您正在谈论 java.sql.Timestamp ,它具有一种称为 setTime java.util.Date 也具有 setTime 方法。

If you are talking about a java.sql.Timestamp, it has a method called setTime. java.util.Date has a setTime method as well for that sort of thing.

您可能会这样:

static final Long duration = ((14 * 60) + 59) * 1000;

oldTimestamp.setTime(oldTimestamp.getTime() + duration);

这篇关于如何为时间戳添加时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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