Java Date Long Format getLongNowTime()

Here you can find the source of getLongNowTime()

Description

get Long Now Time

License

Apache License

Declaration

public static String getLongNowTime() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static final String yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";
    public static final String yyyyMMddHHmmssSS = "yyyy-MM-dd HH:mm:ss.SS";

    public static String getLongNowTime() {
        return getNowTime(yyyyMMddHHmmssSS);
    }//  ww w.ja  v a2s  .  co  m

    public static String getNowTime() {
        return getNowTime(yyyyMMddHHmmss);
    }

    public static String getNowTime(String format) {
        Date nowDate = new Date();
        Calendar now = Calendar.getInstance();
        now.setTime(nowDate);
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        return formatter.format(now.getTime());
    }
}

Related

  1. getLongDisplayTime(long time)
  2. getLongFormatTime(java.util.Date date)
  3. getLongFromDatestamp(String datestamp)
  4. getLongGmtDateString(Date date)
  5. getLongMillis(String date)
  6. getLongOracleDateTime(Date date)
  7. getLongPattern(final Locale locale)
  8. getLongTime()
  9. getLongWeekday(int dayOfWeek)