Java Date Now getCurrent()

Here you can find the source of getCurrent()

Description

get Current

License

Open Source License

Declaration

public static Date getCurrent() 

Method Source Code

//package com.java2s;
/**/*w ww  . ja v a 2 s  .  c  o  m*/
 * Copyright (c)2010-2011 Enterprise Website Content Management System(EWCMS), All rights reserved.
 * EWCMS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * http://www.ewcms.com
 */

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";

    public static Date getCurrent() {
        return getCurrent(DEFAULT_DATE_FORMAT);
    }

    public static Date getCurrent(String format) {
        SimpleDateFormat simple = new SimpleDateFormat(format);
        Date current = new Date(Calendar.getInstance().getTime().getTime());
        try {
            current = simple.parse(simple.format(current));
        } catch (Exception e) {
        }
        return current;
    }
}

Related

  1. currentDateTimeToEasySortedDateTime()
  2. currentGMTDateTime()
  3. currentSystemDate()
  4. currentXdsDate(int format)
  5. getCurrent()
  6. getCurrentAccurateDateTimeStringForPrint()
  7. getCurrentAgeByBirthdate(String brithday)
  8. getCurrentCacheTime()
  9. getCurrentCalendar()