Created
October 10, 2010 16:15
-
-
Save ksky/619359 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #45 日時の演算処理。例えば「現在時刻の3日と4時間後を求める」「特定の時刻間の時間数を求める」 | |
use (groovy.time.TimeCategory) { | |
// 現在時刻の3日と4時間後を求める | |
def now = new Date() | |
def d = now + 3.day + 4.hours | |
println d | |
// 特定の時刻間の時間数を求める | |
def diff = d - now | |
println diff.toMilliseconds() / (60 * 60 * 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment