Here you can find the source of getAge(Date birthday)
Parameter | Description |
---|---|
birthday | a parameter |
public static int getAge(Date birthday)
//package com.java2s; //License from project: Apache License import java.util.Date; import java.util.concurrent.TimeUnit; public class Main { /**/*w w w .ja v a 2 s . c o m*/ * * @param birthday * @return */ public static int getAge(Date birthday) { long day = TimeUnit.DAYS.convert(System.currentTimeMillis() - birthday.getTime(), TimeUnit.MILLISECONDS); return (int) (day / 365); } }