List of usage examples for java.util Calendar getActualMinimum
public int getActualMinimum(int field)
Calendar
. From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // return the minimum value that the year field could have int i = cal.getActualMinimum(Calendar.YEAR); System.out.println("Minimum Year :" + i); // returns the minimum value that the month field could have int a = cal.getActualMinimum(Calendar.MONTH); System.out.println("Minimum month :" + a); }
From source file:Main.java
public static Date firstTimeOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from ww w . j a v a 2 s. co m*/ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); return cal.getTime(); }
From source file:Main.java
public static void clearCalendarSecondWithRear(Calendar cal) { cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); clearCalendarMillisecond(cal);/* ww w. j ava 2s. c o m*/ }
From source file:Main.java
/** * Get current month first day/* w w w .jav a 2 s .c o m*/ * * @return */ public static int getCurrentMonthFirstDay() { Calendar calendar = Calendar.getInstance(); return calendar.getActualMinimum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static Date beginOfThisMonth() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); calendar.set(Calendar.HOUR, calendar.getActualMinimum(Calendar.HOUR)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMinimum(Calendar.MILLISECOND)); return calendar.getTime(); }
From source file:Main.java
public static String getMonthFirstDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); return dateFormat.format(calendar.getTime()); }
From source file:Main.java
public static java.util.Date getDate(int y, int m, int d, boolean inclusive) { java.util.Date dt = null;/*from ww w . ja v a 2 s .com*/ Calendar c = Calendar.getInstance(); c.clear(); if (c.getActualMinimum(1) <= y && y <= c.getActualMaximum(1)) { c.set(1, y); if (c.getActualMinimum(2) <= m && m <= c.getActualMaximum(2)) { c.set(2, m); if (c.getActualMinimum(5) <= d && d <= c.getActualMaximum(5)) c.set(5, d); } if (inclusive) { c.add(5, 1); c.add(14, -1); } dt = c.getTime(); } return dt; }
From source file:Main.java
public static void clearCalendarMinuteWithRear(Calendar cal) { cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); clearCalendarSecondWithRear(cal);//from ww w . jav a 2 s.co m }
From source file:Main.java
public static void clearCalendarMillisecond(Calendar cal) { cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND)); }
From source file:Main.java
public static Calendar getCalendarSetToFirstDayOfNextMonth(Calendar currentMonth) { currentMonth.add(Calendar.MONTH, 1); currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH)); return currentMonth; }