Java DateTimeFormatter getTimeStamp(final String dateTimeFormatPattern)

Here you can find the source of getTimeStamp(final String dateTimeFormatPattern)

Description

Return time stamp formatted corresponding to input dateTimeFormatPattern pattern.

License

Open Source License

Parameter

Parameter Description
dateTimeFormatPattern Input dateTimeFormatPattern pattern. Use DateTimeFormatter pattern conventions.

Return

Formatted timestamp.

Declaration

public static String getTimeStamp(final String dateTimeFormatPattern) 

Method Source Code

//package com.java2s;
/**/*  w  ww .  ja  va2s  .  c  o  m*/
 * Copyright (c) 2016, German Neuroinformatics Node (G-Node)
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted under the terms of the BSD License. See
 * LICENSE file in the root of the Project.
 */

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Main {
    /**
     * Return time stamp formatted corresponding to input dateTimeFormatPattern pattern.
     * @param dateTimeFormatPattern Input dateTimeFormatPattern pattern.
     *                              Use {@link DateTimeFormatter} pattern conventions.
     * @return Formatted timestamp.
     */
    public static String getTimeStamp(final String dateTimeFormatPattern) {
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateTimeFormatPattern));
    }
}

Related

  1. getShortFormatter(Locale locale)
  2. getStartOfDay(Date dateToFormat)
  3. getTime(final String time, final DateTimeFormatter formatter)
  4. getTime(String format)
  5. getTimeFromEpochMilli(String value, boolean shortFormat, String errorText)
  6. getTimestampedPath(Path baseFile, TemporalAccessor time, DateTimeFormatter formatter)
  7. parse(DateTimeFormatter formatter, String string)
  8. parse(final DateTimeFormatter formatter, final String value, final ZoneId zoneId)
  9. parse(String _date, String _format)