zoukankan      html  css  js  c++  java
  • 根据出生日期计年龄

    public int GetAgeByBrithday(Date birthday){
      int age=-1;
      Date today=new Date();
      int todayYear=today.getYear();
      int todayMonth=today.getMonth()+1;
      int todayDay=today.getDate();

      int birthdayYear=birthday.getYear();
      int birthdayMonth=birthday.getMonth();
      int birthdayDay=birthday.getDate();
      if(todayYear-birthdayYear<0)
      {
       FacesContext.getCurrentInstance().addMessage(null,
         new FacesMessage("出生日期选择错误!"));
      }
      else
      {
             if(todayMonth*1-birthdayMonth*1<0)
             {
                    age = (todayYear*1-birthdayYear*1)-1;
             }
             else
             {
                    if(todayDay-birthdayDay>=0)
                    {//alert(thisDay+'-'+brithd+"_ddd");
                           age = (todayYear*1-birthdayYear*1);
                    }
                    else
                    {
                           age = (todayYear*1-birthdayYear*1)-1;
                    }
             }
      }
      return age*1;

     }

  • 相关阅读:
    Spring Boot
    Spring Boot Tomcat配置详解
    Spring Boot读取配置的 5 种方式
    Spring Boot日志集成实战
    Spring Boot国际化开发实战
    Spring Boot整合 Thymeleaf 模板引擎
    Spring Boot Debug调试
    Spring Boot实现热部署
    Exchange Cards(dfs)
    Dungeon Master
  • 原文地址:https://www.cnblogs.com/yongtaiyu/p/2567738.html
Copyright © 2011-2022 走看看