Java Year Day getTodayYear()

Here you can find the source of getTodayYear()

Description

get Today Year

License

Open Source License

Declaration

public static int getTodayYear() 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static int getTodayYear() {
        int yyyy = Integer.parseInt(dateFormat(new Date(), "yyyy"));
        return yyyy;
    }//w  w w .  ja v a  2 s .c  o  m

    public static Date dateFormat(String date, String dateFormat) {
        if (date == null)
            return null;
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        if (date != null)
            try {
                return format.parse(date);
            } catch (Exception ex) {
            }
        return null;
    }

    public static Date dateFormat(String date) {
        return dateFormat(date, "yyyy-MM-dd HH:mm:ss");
    }

    public static String dateFormat(Date date, String dateFormat) {
        if (date == null)
            return "";
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        if (date != null)
            return format.format(date);

        return "";
    }

    public static String dateFormat(Date date) {
        return dateFormat(date, "yyyy-MM-dd HH:mm:ss");
    }
}

Related

  1. getFirstDay4CurrentYear()
  2. getFirstDayOfThisYear()
  3. getLastDayOfTheYear(int year)
  4. getLastDayOfYear(int year)
  5. getLastDayOfYear(int year)
  6. getWeekNumOfYearDay(String strDate)
  7. getYearFirstDay(String date)
  8. getYearLastDay(String dateString)
  9. getYearWeek(String curday)