Java Calendar Time timestamp2Calendar(long timestamp)

Here you can find the source of timestamp2Calendar(long timestamp)

Description

timestamp Calendar

License

Apache License

Declaration

public static Calendar timestamp2Calendar(long timestamp) 

Method Source Code

//package com.java2s;
/**/* w  w  w. j  a va 2s.c  om*/
 * Utils class for the stats
 * S23Y (2015). Licensed under the Apache License, Version 2.0.
 * Author: Thibaud Ledent
 */

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static Calendar timestamp2Calendar(long timestamp) {
        Date date = timestamp2Date(timestamp);
        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("Europe/Brussels"));
        cal.setTime(date);

        return cal;
    }

    /**
     * Converts a unix timestamp in seconds to a Date.
     * @param timestamp a timestamp to convert
     * @return a Date corresponding to the timestamp in unix epoch timestamp (seconds)
     */
    public static Date timestamp2Date(long timestamp) {
        return new Date(timestamp * 1000);
    }
}

Related

  1. setTimeToMinOrMax(Calendar cal, boolean max)
  2. stripTime(final Calendar cal)
  3. stripTimeComponent(Calendar cal)
  4. time2InicioDelDia(Calendar fecha)
  5. timestamp17ToCalendar(String timestamp17String)
  6. timestampToCalendar(String timestamp)
  7. toDefaultTimeZone(Calendar calendar)
  8. toTimeStamp(Calendar cal)
  9. toTimeString(final Calendar calendar)