Похожие чаты

Hey! anyone know how to add and subtract hours? Edit:

Here's an example: I ask 2 times with scanner, then you can add or subtract time. Ex: You put 1 hour 2 min 3 sec, then 2 hours 3 min and 4 sec. Then I ask user to add or subtract the time. If the user put add it will be the result 3 hours 5 min 7 sec.

1 ответов

4 просмотра

If somebody here works with groovy, you may find this useful. Here's how it's done with TimeCategory that enhances Java's Integer class: use(TimeCategory) { def t1 = 1.hour + 2.minutes + 3.seconds def t2 = 2.hours + 3.minutes + 4.seconds def sub = t1 - t2 def add = t1 + t2 }

Похожие вопросы

Обсуждают сегодня

Карта сайта