Java Day of getBirthday(String age)

Here you can find the source of getBirthday(String age)

Description

get Birthday

License

Apache License

Declaration

public static String getBirthday(String age) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

public class Main {
    private static String defaultDatePattern = "yyyy-MM-dd";

    public static String getBirthday(String age) {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.YEAR, -Integer.parseInt(age));
        SimpleDateFormat format = new SimpleDateFormat(defaultDatePattern);
        return format.format(c.getTime());
    }//from  w w w .  j  a va 2  s.c o  m

    public static String format(Date date) {
        return date == null ? "" : format(date, getDatePattern());
    }

    public static String format(Date date, String pattern) {
        return date == null ? "" : new SimpleDateFormat(pattern)
                .format(date);
    }

    public static String getDatePattern() {
        return defaultDatePattern;
    }
}

Related

  1. getBeforeDate(int day)
  2. getBeforeOrAfterDay(Date date, String format, Integer days)
  3. getBeginEndTimeOfDay(Date day)
  4. getBeginOfDay(Date date)
  5. getBeginTimeOfDay(Date date, int offset)
  6. getBirthDay(String idCard)
  7. getBirthDayDateFormat()
  8. getBirthdayFormatStr(Date date)
  9. getBookInfoDate(int days)