Java Timestamp Create getTimestamp()

Here you can find the source of getTimestamp()

Description

get Timestamp

License

Mozilla Public License

Declaration

public static String getTimestamp() 

Method Source Code


//package com.java2s;
/*//  w  ww  . j  a v  a 2s  .  c o m
* ??????? (C) 2000-2007 ????? <TanMenglong@gmail.com>
* 
* ????????Mozilla Public Licene1.1?????????????????????????????
* http://www.mozilla.org/MPL/MPL-1.1.html
*/

import java.util.*;
import java.text.SimpleDateFormat;

public class Main {
    private static Calendar cal = Calendar.getInstance();
    private static SimpleDateFormat sdf = new SimpleDateFormat();

    public static String getTimestamp() {
        return getDate("yyyy-MM-dd HH:mm:ss");
    }

    public static String getDate() {
        sdf.applyPattern("yyyy-MM-dd");
        String date = sdf.format(cal.getTime());
        return date;
    }

    public static String getDate(String patten) {
        sdf.applyPattern(patten);
        String date = sdf.format(cal.getTime());
        return date;
    }
}

Related

  1. createTimestamp(final int year, final int month, final int day, final int hour, final int minute, final int second)
  2. createTimestamp(int month, int day)
  3. createTimestampedZipFilename(String prefix)
  4. createTimestampFormat()
  5. createTimeStamps()
  6. getTimestamp()
  7. getTimestamp()
  8. getTimeStamp()
  9. getTimestamp()