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
@Grab(group='joda-time', module='joda-time', version='*') | |
import org.joda.time.* | |
//def rand_date(def fr, def to) { // java... | |
def rand_date = {fr,to-> // groovy!! | |
def d = new DateTime(fr) | |
def range = Days.daysBetween(d, new DateTime(to)).getDays() + 1 | |
d.plusDays((Integer)Math.floor(Math.random() * range)).toString("yyyy-MM-dd") | |
} |
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
@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") | |
} | |
rand_date ={f,t -> | |
new DateTime(f).random(t) |
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
class DateRange { | |
def range | |
def index = 0 | |
DateRange (f, t) { | |
range = (toDate(f)..toDate(t)).toList().with { | |
Collections.shuffle(it); it | |
} | |
} | |
// 変換処理 |
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
Date.metaClass.getFiscalMonth = { p -> | |
cal = Calendar.getInstance(); | |
cal.setTime(delegate) | |
if (cal.get(Calendar.DATE) > p) { cal.add(Calendar.MONTH, 1) } | |
cal.set(Calendar.DATE, 1) | |
cal.getTime() | |
} | |
Date.metaClass.toString = { | |
delegate.format('yyyy/MM/dd') |
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
class FiscalInfoHolder { | |
def month | |
def date | |
def cal = Calendar.getInstance() | |
// 会計年月度の取得 | |
def getFiscalYearMonth = { | |
cal.setTime(it) | |
if (cal.get(Calendar.DATE) > date) { cal.add(Calendar.MONTH, 1) } | |
cal.getTime() |
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
import javax.print.*; | |
import javax.swing.*; | |
class PrinterUtil { | |
// プリンタ一覧の取得 | |
static def getPrinterList = { | |
List list = [] | |
PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null).each { | |
list.add(it.getName()) |
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
class StopWatch { | |
def lapTimes = [] | |
def startTime | |
def stopTime | |
def cur = { System.currentTimeMillis() } | |
def start = { startTime = cur() } | |
def stop = { stopTime = cur() } | |
def elapsedTime = { stopTime - startTime } | |
def elapsedLapTime = { lapTimes[it].time - startTime } |
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
import javax.swing.*; | |
// VirtualBoxのパス | |
path = "C:\\Program Files\\Oracle\\VirtualBox\\" | |
// 仮想マシンのリスト | |
list = ['RedMine', 'DokuWiki'] | |
// 引数チェック | |
if (args.size() == 0) { |
OlderNewer