Here you can find the source of getTimestampLexical(boolean showSeconds, Locale locale)
Parameter | Description |
---|---|
showSeconds | the show seconds |
locale | the locale |
public static String getTimestampLexical(boolean showSeconds, Locale locale)
//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()); } }