Java Year Get getYear(String strDate)

Here you can find the source of getYear(String strDate)

Description

get Year

License

LGPL

Declaration

public static String getYear(String strDate) 

Method Source Code

//package com.java2s;
/**//from   w  w  w. j  a  v  a  2s . co m
 *
 * Methods Descrip:Converts a line of text into an array of lower case words
 * using a BreakIterator.wordInstance().
 * <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text
 *            a String of text to convert into an array of words
 * @return text broken up into an array of words.
 *
 */

public class Main {

    public static String getYear(String strDate) {
        String year = "";
        if (strDate != null && !strDate.equals("")) {
            strDate = strDate.trim();
            year = getElement(strDate.split("-"), 0);
        }

        return year;
    }

    private static String getElement(String[] strs, int number) {
        String elemenet = "";
        if (strs != null) {
            int length = strs.length;
            if (number > length) {
                elemenet = strs[length];
            } else {
                elemenet = strs[number];
            }
        }
        return elemenet;
    }
}

Related

  1. getYear(String index)
  2. getYear(String referralId)
  3. getYear(String startTime)
  4. getYear(String str_date)
  5. getYear(String strDate)
  6. getYear(String string)
  7. getYear(String tempdat, Locale locale)
  8. getYear(String[] contents)
  9. getYearCount(String from, String to)