Java String Sanitize sanitizeYear(int yr)

Here you can find the source of sanitizeYear(int yr)

Description

sanitize year using the rule of 60, two digit ears >=60 = 1900+yr years less than 60 are 2000+yr.

License

Open Source License

Parameter

Parameter Description
yr The year to sanitize

Return

the year sanitized by rule of 60.

Declaration

public static int sanitizeYear(int yr) 

Method Source Code

//package com.java2s;
/*/*from   www . j av  a2  s .co  m*/
 * Copyright 2011, United States Geological Survey or
 * third-party contributors as indicated by the @author tags.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/  >.
 *
 */

public class Main {
    /** sanitize year using the rule of 60, two digit ears >=60 = 1900+yr
     * years less than 60 are 2000+yr.  If its 4 digits already, just return it.
     * @param yr The year to sanitize
     * @return the year sanitized by rule of 60.
     */
    public static int sanitizeYear(int yr) {
        if (yr >= 100)
            return yr;
        if (yr >= 60 && yr < 100)
            return yr + 1900;
        else if (yr < 60 && yr >= 0)
            return yr + 2000;
        System.out.println("Illegal year to sanitize =" + yr);
        return -1;
    }
}

Related

  1. sanitizeUnicode(String str)
  2. sanitizeUserEmail(String userEmail)
  3. sanitizeUserName(final String userName)
  4. sanitizeVersion(String inVer)
  5. sanitizeWebOutput(String text)