List of usage examples for java.util Calendar DAY_OF_YEAR
int DAY_OF_YEAR
To view the source code for java.util Calendar DAY_OF_YEAR.
Click Source Link
get
and set
indicating the day number within the current year. From source file:Main.java
public static boolean areSameDay(Calendar c1, Calendar c2) { if (c1 == null || c2 == null) { return false; }/*from w ww .jav a 2s . c o m*/ int y1, y2, d1, d2; y1 = c1.get(Calendar.YEAR); y2 = c2.get(Calendar.YEAR); d1 = c1.get(Calendar.DAY_OF_YEAR); d2 = c2.get(Calendar.DAY_OF_YEAR); if (y1 == y2 && d1 == d2) { return true; } return false; }
From source file:Main.java
public static boolean isSameDay(Date date1, Date date2) { Calendar cal1 = buildFromDate(date1); Calendar cal2 = buildFromDate(date2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); }
From source file:Main.java
public static String getTomorrowDate() { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(System.currentTimeMillis()); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from ww w .ja v a2 s . com*/ cal.add(Calendar.DAY_OF_YEAR, +1); return sdf.format(cal.getTime()); }
From source file:Main.java
public static boolean sameDate(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1);// w w w. j a v a 2s .c om cal2.setTime(date2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); }
From source file:Main.java
public static boolean isSameDay(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1);/*www . java2 s . co m*/ Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); }
From source file:Main.java
public static boolean datesOnSameDay(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1);/*from w ww . ja v a2 s . c o m*/ cal2.setTime(date2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); }
From source file:Main.java
public static boolean sameDate(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1);//from www.ja va 2s . c o m cal2.setTime(date2); boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); return sameDay; }
From source file:Main.java
public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) throw new IllegalArgumentException("The dates must not be null"); return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); }
From source file:Main.java
public static boolean isSameDay(Date date1, Date date2) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1);//from w w w . j a v a 2 s . com cal2.setTime(date2); boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); return sameDay; }
From source file:Main.java
public static boolean isSameDate(long d1, long d2) { Calendar cal1 = Calendar.getInstance(); cal1.setTimeInMillis(d1);//from www .j av a 2s. com Calendar cal2 = Calendar.getInstance(); cal2.setTimeInMillis(d2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR); }