Java Timestamp Format getFormattedTimestamp()

Here you can find the source of getFormattedTimestamp()

Description

Gets a properly formatted timestamp.

License

Open Source License

Return

a formatted timestamp

Declaration

private static String getFormattedTimestamp() 

Method Source Code


//package com.java2s;
/*//from   w  ww .  j a v a 2s .  c  o m
 * Copyright (c) 2009 Netcetera AG and others.
 * All rights reserved.
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0 which accompanies this
 * distribution, and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * - Netcetera AG: initial implementation
 */

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

public class Main {
    private static final String DATEFORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss";

    /**
     * Gets a properly formatted timestamp.
     *
     * @return a formatted timestamp
     */
    private static String getFormattedTimestamp() {
        return new SimpleDateFormat(DATEFORMAT_PATTERN, Locale.US).format(new Date());
    }
}

Related

  1. getEpochTime(String dateTimeStamp, SimpleDateFormat dateFormat)
  2. getFormatForTimestamp( final Calendar now, final Calendar timestamp)
  3. getFormattedDate(String timestamp)
  4. getFormattedDateFromTimestamp(long timestamp)
  5. getFormattedTime(long timestamp, String format)
  6. getFormattedTimestamp(@Nonnull Date date)
  7. getFormattedTimestamp(File file)
  8. getFormattedTimeStamp(long timestamp, String formatString)
  9. getFullTimestampFormatter(Locale locale)