Java Today getTodayDate()

Here you can find the source of getTodayDate()

Description

get Today Date

License

Open Source License

Declaration

public static Date getTodayDate() throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

import java.util.Date;

public class Main {
    public static final String ENCOUNTER_DATE_PATTERN = "yyyy-M-d";

    public static Date getTodayDate() throws ParseException {
        DateFormat dateFormat = new SimpleDateFormat(ENCOUNTER_DATE_PATTERN);
        Date date = new Date();
        String dateString = dateFormat.format(date);
        return getDateFromString(dateString);
    }/* w  w  w . ja  v a2 s. co  m*/

    public static Date getDateFromString(String dateString) throws ParseException {
        // All csv imports use the same date format
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ENCOUNTER_DATE_PATTERN);
        simpleDateFormat.setLenient(false);
        return simpleDateFormat.parse(dateString);
    }
}

Related

  1. getToday(String formatString)
  2. getToday(String time)
  3. getTodayAsLong()
  4. getTodayAsSecond()
  5. getTodayDate()
  6. getTodayDate()
  7. getTodayDateAsString()
  8. getTodayDateInString()
  9. getTodayDbFormat()