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 int getMonthOfDays(int year, int month) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    return calendar.getActualMaximum(Calendar.DATE);
}

From source file:Main.java

public static String getCurrentDateString() {
    Calendar calendar = Calendar.getInstance();
    return calendar.get(Calendar.YEAR) + "-" + String.format("%02d", (calendar.get(Calendar.MONTH) + 1)) + "-"
            + String.format("%02d", calendar.get(Calendar.DATE));
}

From source file:Main.java

public static String getNowDataForTextView() {
    return Calendar.getInstance().get(Calendar.YEAR) + "-" + getNowDataForChart();
}

From source file:Main.java

public static int getWeekOfFirstDay(int year, int month) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    return calendar.get(Calendar.DAY_OF_WEEK);
}

From source file:Main.java

public static Calendar todaysCalendar() {
    Calendar now = Calendar.getInstance();
    return createNewCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
            now.get(Calendar.DAY_OF_MONTH));
}

From source file:Main.java

public static int getYear() {
    Calendar now = Calendar.getInstance();
    return now.get(Calendar.YEAR);
}

From source file:Main.java

public static int getAnioVigenciaPosition(String vigenciaAnio) {
    Calendar c = Calendar.getInstance();
    int anio = c.get(Calendar.YEAR);

    String anioInicial = String.valueOf(anio).substring(2, 4);
    int inicial = Integer.parseInt(anioInicial);
    int fin = Integer.parseInt(vigenciaAnio);

    return fin - inicial;
}

From source file:Main.java

public static String getTodayDateString() {
    Calendar now = Calendar.getInstance();
    int year = now.get(Calendar.YEAR);
    int month = now.get(Calendar.MONTH) + 1;
    int day = now.get(Calendar.DAY_OF_MONTH);

    String monthStr = String.valueOf(month);
    String dayStr = String.valueOf(day);

    if (month < 10) {
        monthStr = "0" + dayStr;
    }/*from   www  .j a v  a2  s . c  o  m*/
    if (day < 10) {
        dayStr = "0" + dayStr;
    }

    String nowDate = year + "-" + monthStr + "-" + dayStr;
    return nowDate;
}

From source file:Main.java

public static Integer[] comboanionacimiento() {

    Integer[] res = new Integer[121];
    for (int i = (Calendar.getInstance().get(Calendar.YEAR) - 120), j = 0; i <= (Calendar.getInstance()
            .get(Calendar.YEAR)); i++, j++) {
        res[j] = i;//from  ww  w.j  a  va  2s .c o m
    }
    return res;
}

From source file:Main.java

public static int getYear(Date date) {
    return getCalendar(date).get(Calendar.YEAR);
}