Created
June 13, 2011 06:39
-
-
Save xnrghzjh/1022390 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
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') | |
} | |
def toDate = { Date.parse('yyyy/MM/dd', it) } | |
// Test | |
println toDate('2011/06/20').getFiscalMonth(20).toString() | |
println toDate('2011/06/21').getFiscalMonth(20).toString() | |
println toDate('2011/06/30').getFiscalMonth(99).toString() | |
println toDate('2011/07/01').getFiscalMonth(99).toString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment