Java Milliseconds CreateDate(long milliseconds)

Here you can find the source of CreateDate(long milliseconds)

Description

Convenience method for creating a date object.

License

Open Source License

Parameter

Parameter Description
milliseconds Time in milliseconds.

Return

Date object

Declaration

public static Date CreateDate(long milliseconds) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.*;

public class Main {
    /** Convenience method for creating a date object.
     */*from  ww w  .j  ava  2  s  .c o m*/
     * @param year Year
     * @param month Month
     * @param day Day
     * @return Date object
     */
    public static Date CreateDate(int year, int month, int day) {
        return CreateDate(year, month, year, 0, 0, 0);
    }

    /** Convenience method for creating a date object.
     *
     * @param year Year
     * @param month Month
     * @param day Day
     * @param hour Hour
     * @param minute Minute
     * @param second Second
     * @return Date object
     */
    public static Date CreateDate(int year, int month, int day, int hour, int minute, int second) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day, hour, minute, second);
        return cal.getTime();
    }

    /** Convenience method for creating a date object.
     *
     * @param milliseconds Time in milliseconds.
     * @return Date object
     */
    public static Date CreateDate(long milliseconds) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(milliseconds);
        return cal.getTime();
    }
}

Related

  1. calcDate(long millisecs)
  2. calculateDaysBackIntoMilliseconds(Integer value)
  3. calculateHMSFromMilliseconds(long timeInMilliSeconds)
  4. computeEclipseTimeMilliseconds(final long beginTime)
  5. concatMillis(String name)
  6. createFromMillis(long milliseconds)
  7. csvAnnotatedMilliString(long totaltime)
  8. cutoffTimeMillis(long time)
  9. cyclesToMillis(long cycles, double hz)