5
5

More than 5 years have passed since last update.

Groovyでn日前の日付を求める

Posted at

Groovyの場合、java.util.Date型で - (マイナス演算子) が使えるので、それで計算できる。

def beforeN(int n) {
  new Date() - n 
}
// 例: 100日前
println beforeN(100)
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5