Java Year Get getYearString()

Here you can find the source of getYearString()

Description

get Year String

License

Open Source License

Declaration

public static String getYearString() 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static final String yearFormat = "yyyy";

    public static String getYearString() {
        return getFormat(yearFormat).format(new Date());
    }/*from w ww.  j  a v  a2 s  .c o  m*/

    public static final String format(Date date, String formate) {
        if (date == null) {
            return "";
        }
        return getFormat(formate).format(date);
    }

    public static final String format(Long dateTmie, String formate) {
        Date date = new Date(dateTmie);
        return getFormat(formate).format(date);
    }

    public static final DateFormat getFormat(String format) {
        return new SimpleDateFormat(format);
    }
}

Related

  1. getYearList(int years)
  2. getYearLongDesc(Date year)
  3. getYearlyIntervals(Date start, Date end)
  4. getYearName(String dateString)
  5. getYearsOfAge(Date birthDate, Date nowDate)
  6. getYearWeek(int year, int week)