Created
October 10, 2010 09:32
-
-
Save nobusue/619108 to your computer and use it in GitHub Desktop.
This file contains 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 #92 TimeCategory | |
def now = new Date() | |
use (groovy.time.TimeCategory) { | |
//このクロージャの内部のみ、Integer型にメソッドが追加されたことになる | |
//例えば以下のようにして9時間5分後を求めることが可能 | |
tgt = now + 9.hours + 5.minutes | |
} | |
// Date.format()はGDK(SimpleDateFormatのショートカット) | |
println now.format('yyyy/MM/dd HH:mm:ss') | |
println tgt.format('yyyy/MM/dd HH:mm:ss') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment