Example usage for java.util Calendar YEAR

List of usage examples for java.util Calendar YEAR

Introduction

In this page you can find the example usage for java.util Calendar YEAR.

Prototype

int YEAR

To view the source code for java.util Calendar YEAR.

Click Source Link

Document

Field number for get and set indicating the year.

Usage

From source file:Main.java

public static long getTimesMonthMorning() {
    Calendar cal = Calendar.getInstance();
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
    return cal.getTimeInMillis();
}

From source file:Main.java

public static int getYearFromDate(Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);//from  w w  w  . j  a  v a  2  s .  c  om
    return c.get(Calendar.YEAR);
}

From source file:Main.java

private static Calendar getCurrentExpDate() {
    Calendar now = Calendar.getInstance();
    now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 0, 0, 0);
    return now;// w ww  .ja v  a  2 s .com
}

From source file:Main.java

public static long intID() {
    Calendar c = Calendar.getInstance();

    int dia = c.get(Calendar.DAY_OF_MONTH);
    int ano = c.get(Calendar.YEAR) - 2010;
    int mes = c.get(Calendar.MONTH) + 1;

    int hora = c.get(Calendar.HOUR_OF_DAY);
    int minuto = c.get(Calendar.MINUTE);
    int segundo = c.get(Calendar.SECOND);
    int milisec = c.get(Calendar.MILLISECOND);

    return Long.parseLong("" + ano + mes + dia + hora + minuto + segundo + milisec);
}

From source file:Main.java

public static int GetYear(boolean lastTwoDigitOnly) {
    Calendar now = Calendar.getInstance();
    if (!lastTwoDigitOnly)
        return now.get(Calendar.YEAR);
    else//from w  w w . j a  v a2s .  c  om
        return Integer.parseInt(String.valueOf(now.get(Calendar.YEAR)).substring(2, 4));
}

From source file:Main.java

public static List<String> GetYearList(int count) {
    int year = Calendar.getInstance().get(Calendar.YEAR);

    List<String> yearList = new ArrayList<String>();

    for (int i = year - count; i <= year; i++) {
        yearList.add(Integer.toString(i));
    }/*from  www. ja  v a 2s.  c  o m*/

    return yearList;
}

From source file:Main.java

public static int year() {
    return calendar().get(Calendar.YEAR);
}

From source file:Main.java

public static String getFirstDayOfMonth(int year, int month) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE));
    return new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
}

From source file:Main.java

public static String getCurrentYear() {
    Calendar calendar = Calendar.getInstance();
    return Integer.toString(calendar.get(Calendar.YEAR));
}

From source file:Main.java

public static Calendar nextBirthday(Calendar today, Calendar dayOfBirth) {
    Calendar nextBirthday = (Calendar) dayOfBirth.clone();
    nextBirthday.set(Calendar.YEAR, today.get(Calendar.YEAR));
    if (nextBirthday.before(today)) {
        nextBirthday.add(Calendar.YEAR, 1);
    }/*from  ww w. j  a va2  s.c o  m*/
    return nextBirthday;
}