Java String to Timestamp calculateClientRequestId(String timestamp)

Here you can find the source of calculateClientRequestId(String timestamp)

Description

This method is used to calculate the clientRequestId parameter of a request.

License

Open Source License

Parameter

Parameter Description
timestamp the timestamp to generate clientRequestId from. It should be in "yyyyMMddHHmmss" format

Return

the clientRequestId or -1 if it can't be calculated

Declaration

public static String calculateClientRequestId(String timestamp) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

    /**/*from www. j  a v  a2s . c o m*/
     * This method is used to calculate the clientRequestId parameter of a request.
     *
     * @param timestamp the timestamp to generate clientRequestId from. It should be in "yyyyMMddHHmmss" format
     * @return the clientRequestId or -1 if it can't be calculated
     */
    public static String calculateClientRequestId(String timestamp) {
        try {
            return String.valueOf(sdf.parse(timestamp).getTime());
        } catch (ParseException e) {
            return "-1";
        }
    }
}

Related

  1. getFileNameWithTimeStampInterposed(final String fileName)
  2. getStringToTimestamp(String string)
  3. getTimeStamp(String date)
  4. getTimeStamp(String dateTime)