Java String to Timestamp getTimestamp(String timeStampStr, String logRundateIdStr)

Here you can find the source of getTimestamp(String timeStampStr, String logRundateIdStr)

Description

get Timestamp

License

Open Source License

Declaration

public static String getTimestamp(String timeStampStr, String logRundateIdStr) 

Method Source Code


//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String getTimestamp(String timeStampStr, String logRundateIdStr) {
        SimpleDateFormat timeDf = new SimpleDateFormat("yyyyMMdd");
        String resultValue = "0";
        try {/*  w w  w .  j  a v a 2  s.  com*/
            new Date(Long.valueOf(timeStampStr) * 1000);
            resultValue = timeStampStr;
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            try {
                Date date = timeDf.parse(logRundateIdStr);
                resultValue = date.getTime() / 1000 + "";
            } catch (ParseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        return resultValue;

    }
}

Related

  1. getTimeStamp(String dateTime)
  2. getTimestamp(String dateValue, String pattern, TimeZone timezone)
  3. getTimestamp(String pattern)
  4. getTimeStamp(String pattern, String strDate)
  5. getTimeStamp(String style, Date date)
  6. getTimestamp(String timezone, String dateTime, String pattern)
  7. getTimestampFromDateString(String date)
  8. getTimeStampInSecond(String timeStr)
  9. isTimestamp(String str, boolean allowEmpty)