Skip to content

Instantly share code, notes, and snippets.

@ksky
Created October 10, 2010 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksky/619359 to your computer and use it in GitHub Desktop.
Save ksky/619359 to your computer and use it in GitHub Desktop.
// 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