Java Year Get getThisYear()

Here you can find the source of getThisYear()

Description

get This Year

License

Apache License

Declaration

public static String getThisYear() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String getThisYear() {
        String dateString = "";

        java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(
                "yyyy");
        java.util.Date currentTime_1 = new java.util.Date();
        dateString = formatter.format(currentTime_1);

        return dateString;
    }//from   w  w w  .java2s  . co  m

    public static String format(Date date) {
        return date == null ? "" : format(date, getDatePattern());
    }

    public static String format(Date date, String pattern) {
        return date == null ? "" : new SimpleDateFormat(pattern)
                .format(date);
    }

    public static String getDatePattern() {
        return defaultDatePattern;
    }
}

Related

  1. getSpecficYearEnd(Date date, int amount)
  2. getStartEndOFWeek(int enterWeek, int enterYear)
  3. getStartOfYear()
  4. getThisYear()
  5. getThisYear()
  6. getTwoDigitYear()
  7. getTwoYearsBefore(int date)
  8. getWeekOfYear(Date date)
  9. getWeekStartEndDate(int timeInfo, String yearInfo)