Java Week of Year getWeekOfYearFromTimestamp(long ms)

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

Description

get Week Of Year From Timestamp

License

Open Source License

Declaration

public static int getWeekOfYearFromTimestamp(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 getWeekOfYearFromTimestamp(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  ww.j a  va  2 s  .  co  m
        return cal.get(Calendar.WEEK_OF_YEAR);
    }
}

Related

  1. getWeekOfPreYearWeek(int year, int week)
  2. getWeekOfYear()
  3. getWeekOfYear(String year, String month, String day)
  4. getWeekOfYearByDay(String year, String month, String day)