List of usage examples for java.util Calendar YEAR
int YEAR
To view the source code for java.util Calendar YEAR.
Click Source Link
get
and set
indicating the year. From source file:Main.java
public static int getMonth(int year, int week) { Calendar calendar = Calendar.getInstance(); calendar.clear();//w w w . j a v a 2 s . com calendar.set(Calendar.YEAR, year); calendar.set(Calendar.WEEK_OF_YEAR, week); return calendar.get(Calendar.MONTH) + 1; }
From source file:Main.java
private static long beginningOfTheDay(Calendar time) { Calendar copy = (Calendar) time.clone(); copy.clear();/*from w w w.j ava 2 s .c o m*/ copy.set(time.get(Calendar.YEAR), time.get(Calendar.MONTH), time.get(Calendar.DAY_OF_MONTH)); return copy.getTimeInMillis(); }
From source file:Main.java
public static int getDays(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.clear();//from www .ja v a 2 s .co m calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); return days; }
From source file:Main.java
public static boolean isOver18(int year, int month, int day) { Calendar cal = Calendar.getInstance(); int months = (cal.get(Calendar.YEAR) - year) * 12; months += cal.get(Calendar.MONTH) - month; int age = months / 12; if (age < 18 || (age == 18 && day > cal.get(Calendar.DAY_OF_MONTH))) { return false; }//from w ww .ja va 2s. com return true; }
From source file:Main.java
public static String[] getListOfCarYears() { String years = ""; Calendar cal = Calendar.getInstance(); for (int i = cal.get(Calendar.YEAR) + 1; i > cal.get(Calendar.YEAR) - 25; i--) { years += i + ","; }//from w w w . jav a 2 s . com return years.substring(0, years.length() - 1).split(","); }
From source file:Main.java
public static int getDayOfWeek(int year, int week) { Calendar calendar = Calendar.getInstance(); calendar.clear();/* w ww .j a va2s . c o m*/ calendar.set(Calendar.YEAR, year); calendar.set(Calendar.WEEK_OF_YEAR, week); return calendar.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getCurrentYear() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR); }
From source file:Main.java
public static boolean isCurrentDate(Calendar comparedDate) { Calendar cal = Calendar.getInstance(); int[] comparedElements = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH }; for (int elem : comparedElements) { if (cal.get(elem) != comparedDate.get(elem)) { return false; }/*from ww w . j ava 2s.c o m*/ } return true; }
From source file:Main.java
public static int getCurrentYear() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); return c.get(Calendar.YEAR); }
From source file:Main.java
public static int getYear() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.YEAR); return year;/*from w w w .j a v a2s .c o m*/ }