Here you can find the source of getTimestamp(String format)
Parameter | Description |
---|---|
format | the format |
public static String getTimestamp(String format)
//package com.java2s; /**/*from ww w . j a va 2 s . c o m*/ * Copyright (c) 2014 Far Eastone Telecommunications Co., Ltd. * All Rights Reserved. * * This software is the confidential and proprietary information of * Far Eastone Telecommunications Co., Ltd. ("Confidential Information"). * * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of license agreement you entered * into with Far Eastone Telecommunications Co., Ltd. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * Get timestamp. * * @param format the format * @return string */ public static String getTimestamp(String format) { return _datetime(format); } /** * Assign return data format. * * @param format the format * @return string */ private static String _datetime(String format) { return _datetime(format, new Date()); } /** * Assign return data format. * * @param format the format * @param date the date * @return string */ private static String _datetime(String format, Date date) { SimpleDateFormat formater = new SimpleDateFormat(format); return formater.format(date).toString(); } /** * Assign return data format (by Locale). * * @param format the format * @param date the date * @param locale the locale * @return string */ private static String _datetime(String format, Date date, Locale locale) { SimpleDateFormat formater = new SimpleDateFormat(format, locale); return formater.format(date).toString(); } }