Java Date Calculate calculateTimestamp()

Here you can find the source of calculateTimestamp()

Description

This method is used to calculate the current timestamp of a request.

License

Open Source License

Return

the current time as a String

Declaration

public static String calculateTimestamp() 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

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

    /**/* www .j av a 2s .co  m*/
     * This method is used to calculate the current timestamp of a request.
     * <p>
     * The format of the returned String is "yyyyMMddHHmmss".
     *
     * @return the current time as a String
     */
    public static String calculateTimestamp() {
        Calendar cal = new GregorianCalendar();
        sdf.setTimeZone(cal.getTimeZone());
        return sdf.format(cal.getTime());
    }
}

Related

  1. calculateNextSettleDate(Date date, int addMonth)
  2. calculateOffsetFromGMT(Date date)
  3. calculatePastDate(int days)
  4. calculateTime(Date date, String addpart, int num)
  5. calculateTime(Date sendTime, String timeZoneID)
  6. calculateTruncatedTime(final Date dateTimeBegin, final Date dateTimeEnd, final Date begin, final Date end)
  7. calculateTruncatedTimeByDays( final Date dateTimeStart, final Date dateTimeEnd, final Date start, final Date end)
  8. calculationAge(Date birthday, Date calculateDay)
  9. getDateCalculate(int d)