Java Now calNow()

Here you can find the source of calNow()

Description

cal Now

License

Apache License

Return

the formatted current

Declaration

public static String calNow() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    public static final String DATE_FORMAT_NOW = "yyyy-MM-dd hh:mm:ss";

    /**//from w  ww .j  a  va  2s  .  c o  m
     * @return the formatted current {@linkplain Calendar}
     */
    public static String calNow() {
        return calFormat(Calendar.getInstance());
    }

    /**
     * Formats a {@linkplain Calendar} to the application wide format for
     * date/time
     * 
     * @param cal
     *            the {@linkplain Calendar} to format
     * @return the formated {@linkplain Calendar}
     */
    public static String calFormat(final Calendar cal) {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
        return sdf.format(cal.getTime());
    }
}

Related

  1. compareDateWithNow(Date date1)
  2. compareWithNow_2(String t)
  3. formatNow()
  4. formatNow()