Java Year From year()

Here you can find the source of year()

Description

year

License

Open Source License

Declaration

public static String year() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static String year() {
        return now("yyyy");
    }//from   ww w .jav a2 s  .com

    public static String now(String s) {
        SimpleDateFormat simpledateformat = new SimpleDateFormat(s);
        Date date = new Date();
        GregorianCalendar gregoriancalendar = new GregorianCalendar();
        gregoriancalendar.setTime(date);
        Date date1 = gregoriancalendar.getTime();
        String s1 = simpledateformat.format(date1);
        return s1;
    }

    public static String now(String s, Date date) {
        SimpleDateFormat simpledateformat = new SimpleDateFormat(s);
        String s1 = simpledateformat.format(date);
        return s1;
    }

    public static String now() {
        return now("yyyy-MM-dd HH:mm:ss");
    }
}

Related

  1. getYearStartTime()
  2. isInYear(String dateStr, int year)
  3. setYears(Date date, int amount)
  4. toNowYear(Date date)
  5. toShortW3CDTF(Date d, boolean yearOnly)
  6. year(Date date)
  7. year(long time)
  8. yearformMatDate(Date date)
  9. yearFromDate(String date)