Java TimeUnit Usage getAge(Date birthday)

Here you can find the source of getAge(Date birthday)

Description

get Age

License

Apache License

Parameter

Parameter Description
birthday a parameter

Declaration

public static int getAge(Date birthday) 

Method Source Code

//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);
    }
}

Related

  1. formatTimeDuration(long duration)
  2. formatTimeInMilliSeconds(long duration)
  3. formatUptime(long startTime)
  4. formatUptime(long uptimeInMs)
  5. generateRandomDateTimeForLogEvent(Date laterThan)
  6. getAge(long currentTimeMillis, long headerTimestampSec)
  7. getAllCombinations( ArrayList lengths)
  8. getAllDaysCount(final long milliseconds)
  9. getBookingDays(Calendar start, Calendar end)