-
-
Save kyonmm/1016168 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
@Grab(group='joda-time', module='joda-time', version='*') | |
import org.joda.time.* | |
DateTime.metaClass.random ={t-> | |
def range = Days.daysBetween(delegate, new DateTime(t)).getDays() + 1 | |
delegate.plusDays(Math.floor(Math.random() * range) as int).toString("yyyy-MM-dd") | |
} | |
5.times{ | |
println new DateTime("1978-09-30").random("2011-10-10") | |
} |
Author
kyonmm
commented
Jun 9, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment