Java Time Now getNowTime(String format)

Here you can find the source of getNowTime(String format)

Description

get Now Time

License

Apache License

Declaration

public static String getNowTime(String format) 

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 String getNowTime() {
        return getNowTime(yyyyMMddHHmmss);
    }// www. j av  a2  s.c  o  m

    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. getNowTime()
  2. getNowTime()
  3. getNowTime()
  4. getNowTime()
  5. getNowTime()
  6. getNowTime(String format, Locale loc)
  7. getNowTime(String formatStr)
  8. getNowWithLocal(boolean ifdatetime)
  9. getNowYearMonth()