Java Unix Date parseUnixDate(String paramName, String dateStr)

Here you can find the source of parseUnixDate(String paramName, String dateStr)

Description

Tries to parse unix date.

License

Open Source License

Parameter

Parameter Description
paramName a parameter
dateStr a parameter

Declaration

public static Calendar parseUnixDate(String paramName, String dateStr) throws IllegalArgumentException 

Method Source Code

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

import java.util.Calendar;

public class Main {
    /**/*from  w  ww. ja  v a 2s.co  m*/
     * Tries to parse unix date. Throws exception if fails.
     * 
     * @param paramName
     * @param dateStr
     * @return
     */
    public static Calendar parseUnixDate(String paramName, String dateStr) throws IllegalArgumentException {
        Calendar day;
        try {
            day = Calendar.getInstance();
            long ms = Long.parseLong(dateStr);
            day.setTimeInMillis(ms);
        } catch (Exception e) {
            throw new IllegalArgumentException("Unparsable \"" + paramName + "\". Must be UTC time in ms", e);
        }

        return day;
    }
}

Related

  1. getUnixDate(Date date)
  2. getUnixDate(long millis)
  3. getUnixDate(String s)
  4. getUnixTime(String dateTime)
  5. getUnixTime2NoneTime(String longTime)
  6. stringUnixTime(String start, String end)
  7. toUnixTime(Date date)
  8. toUnixTime(SimpleDateFormat simpleDateFormat, String audioboxDate)
  9. unixTime()