Java Timestamp Create getTimestampLexical(boolean showSeconds, Locale locale)

Here you can find the source of getTimestampLexical(boolean showSeconds, Locale locale)

Description

Gets timestamp lexical.

License

Apache License

Parameter

Parameter Description
showSeconds the show seconds
locale the locale

Return

the timestamp lexical

Declaration

public static String getTimestampLexical(boolean showSeconds, Locale locale) 

Method Source Code

//package com.java2s;
/*/*  ww w .  j a va  2 s .c  o m*/
 * Copyright (c) 2016 Martin Pfeffer
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    /**
     * Gets timestamp lexical.
     *
     * @param showSeconds the show seconds
     * @return the timestamp lexical
     */
    public static String getTimestampLexical(boolean showSeconds) {
        if (showSeconds)
            return new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
        else
            return new SimpleDateFormat("yyyyMMddhhmm").format(new Date());
    }

    /**
     * Gets timestamp lexical.
     *
     * @param showSeconds the show seconds
     * @param locale      the locale
     * @return the timestamp lexical
     */
    public static String getTimestampLexical(boolean showSeconds, Locale locale) {
        if (showSeconds)
            return new SimpleDateFormat("yyyyMMddhhmmss", locale).format(new Date());
        else
            return new SimpleDateFormat("yyyyMMddhhmm", locale).format(new Date());
    }
}

Related

  1. getTimestampFromString(String dateString, String dateFormat)
  2. getTimestampFromString(String id)
  3. getTimestampFromString(String s)
  4. getTimeStampFromString(String timeStamp)
  5. getTimestampInEnglish(java.sql.Timestamp t)
  6. getTimestampMinusDays(Integer days)
  7. getTimestampNullSafe(final Date ts)
  8. getTimestampOrNull(Object dbResult)
  9. getTimeStampString()