Java Year From getYear(long t)

Here you can find the source of getYear(long t)

Description

get Year

License

LGPL

Declaration

public static int getYear(long t) 

Method Source Code

//package com.java2s;
/**/*  www.j ava2 s  . co  m*/
 * 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.
 */

import java.util.Calendar;

import java.util.Date;

public class Main {
    public static int getYear(long t) {
        Calendar cld = Calendar.getInstance();
        if (t > 0) {
            cld.setTime(new java.util.Date(t));
        }
        return cld.get(Calendar.YEAR);
    }

    public static int getYear(Date date) {
        Calendar cld = Calendar.getInstance();
        cld.setTime(date);
        return cld.get(Calendar.YEAR);
    }

    public static int getYear() {
        Calendar cld = Calendar.getInstance();
        cld.setTime(new java.util.Date());
        return cld.get(Calendar.YEAR);
    }
}

Related

  1. getYear(boolean fourDigit)
  2. getYear(int num)
  3. getYearBegin(int year)
  4. getYearFirst(int year)
  5. getYearFormat(String dateString)
  6. getYearFromDay(int days)