Java Year From getYearFromTimestamp(long ms)

Here you can find the source of getYearFromTimestamp(long ms)

Description

get Year From Timestamp

License

Open Source License

Declaration

public static int getYearFromTimestamp(long ms) throws NumberFormatException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
    public static final Locale LOCALE = new Locale("sv", "SE");

    public static int getYearFromTimestamp(long ms) throws NumberFormatException {
        if (ms < 0)
            throw new NumberFormatException("argument must be positive");
        Calendar cal = Calendar.getInstance(TIMEZONE, LOCALE);
        cal.setTimeInMillis(ms);//from  w  w  w  . j a va  2s .  co  m
        return cal.get(Calendar.YEAR);
    }
}

Related

  1. getYearBegin(int year)
  2. getYearFirst(int year)
  3. getYearFormat(String dateString)
  4. getYearFromDay(int days)
  5. getYearFromISODate(String isoDate)
  6. getYearFromWeekCode(String weekCode)
  7. getYearFromYM(String ym)
  8. getYearMonth(String day)
  9. getYearMonthArray(Integer yearMonth)