Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须编写一个 java 代码来将分钟(delayminutes)添加到时间戳(tmpTimeStamp)。这就是我所拥有的。我想知道这是否是一种有效的方法,或者是否有更好的方法。
long t=tmpTimeStamp.getTime(); long m=delayMinutes*60*1000; targetDeliveryStamp= new Timestamp(t+m);
这很不错。如果您可以重用临时时间戳,则可以稍微提高效率并避免对象构造开销:
tmpTimeStamp.setTime(tmpTimeStamp.getTime() + TimeUnit.MINUTES.toMillis(delayMinutes));