3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DateTimeFormatterなんか使い方間違ってる??

Last updated at Posted at 2016-01-08
groovy> import java.time.LocalDate; 
groovy> import java.time.ZoneId; 
groovy> import java.time.format.DateTimeFormatter; 
groovy> def date = LocalDate.of(2015,12,29) 
groovy> println date 
groovy> date.format(DateTimeFormatter.ofPattern("YYYY.MM", Locale.getDefault())) 
 
2015-12-29
Result: 2016.12

2015.12って表示してほしいんだけど。。。

追記)わかった。。。

大文字のYはその週が何年かってのを出すらしい。

date.format(DateTimeFormatter.ofPattern("YYYY.MM", Locale.getDefault()))
date.format(DateTimeFormatter.ofPattern("yyyy.MM", Locale.getDefault()))
3
3
1

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?