4
2

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.

生年月日から年齢を計算する

4
Last updated at Posted at 2017-07-13

生年月日から年齢計算

生年月日が入ったLocalDate を渡す

private fun calcAge(birthday: LocalDate): Int? {
  val today = LocalDate.now()
  return Period.between(LocalDate.parse(birthday.toString()), today).getYears()
}
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?