Java Date from String getDateFromTime(long millisSinceMidnight)

Here you can find the source of getDateFromTime(long millisSinceMidnight)

Description

get Date From Time

License

Creative Commons License

Return

the first date in 1970 with millisSinceMidnight added to it

Declaration

public static Date getDateFromTime(long millisSinceMidnight) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

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

public class Main {
    /**//  w  w w. j av a  2 s  .  co m
     * @return the first date in 1970 with millisSinceMidnight added to it 
     */
    public static Date getDateFromTime(long millisSinceMidnight) {

        Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC +0"));
        Date date = new Date();
        date.setTime(millisSinceMidnight);
        cal.setTime(date);

        return cal.getTime();
    }
}

Related

  1. getDateFromReccurenceInterval(int reqDOW, int reqDOM, int time)
  2. getDateFromStartTime(String startTime)
  3. getDateFromString(String s)
  4. getDateFromString(String strDate, String strTime)
  5. getDateFromString(String stringDate)