Java Now Now()

Here you can find the source of Now()

Description

Now

License

Open Source License

Declaration

public static Date Now() throws ParseException 

Method Source Code


//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static Date Now() throws ParseException {
        return dateFormat.parse(format());
    }//from  w  ww.j a  v a2s.  c  o m

    public static String format() {
        Date date = new Date();
        return dateFormat.format(date);
    }

    public static String format(String datestr) {
        Date date;
        try {
            date = dateFormat.parse(datestr);
        } catch (ParseException e) {
            date = new Date();
        }
        return dateFormat.format(date);
    }
}

Related

  1. now()
  2. now()
  3. now()
  4. now()
  5. now()
  6. now()
  7. now()
  8. now()
  9. now()