List of usage examples for java.util Calendar set
public final void set(int year, int month, int date)
YEAR
, MONTH
, and DAY_OF_MONTH
. From source file:Main.java
public static boolean isDateSize(int[] oneDate, int[] twoDate) { Calendar oneCalendar = Calendar.getInstance(); Calendar twoCalendar = Calendar.getInstance(); oneCalendar.set(oneDate[0], oneDate[1] - 1, oneDate[2]); twoCalendar.set(twoDate[0], twoDate[1] - 1, twoDate[2]); return twoCalendar.after(oneCalendar); }
From source file:Main.java
/** * Creates a Calendar instance for the given year, month (1-based), and day * (1-based) in the default time zone// ww w . j a v a 2s . c om */ public static Calendar createDate(int year, int month, int day) { Calendar date = Calendar.getInstance(); date.clear(); date.set(year, month - 1, day); // Months start at 0 for Calendar! return date; }
From source file:Main.java
/** * Creates a Calendar instance for the given year, month (1-based), and day * (1-based) in the given time zone//from www. ja va 2 s.c om */ public static Calendar createDate(TimeZone timeZone, int year, int month, int day) { Calendar date = Calendar.getInstance(timeZone); date.clear(); date.set(year, month - 1, day); // Months start at 0 for Calendar! return date; }
From source file:org.jfree.chart.demo.GanttDemo3.java
private static Date date(int i, int j, int k) { Calendar calendar = Calendar.getInstance(); calendar.set(k, j, i); Date date1 = calendar.getTime(); return date1; }
From source file:Main.java
/** * Calculates the number of days between Epoch and the given date. * * @param date the date.//www . j av a 2 s . c o m * @return the number of days between Epoch and the given date. */ public static int daysSince1900(Date date) { final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(1900, 0, 1); return daysBetween(calendar.getTime(), date); }
From source file:Main.java
public static void setToFirstDay(Calendar calendar) { int year = getYear(calendar); int month = getMonth(calendar); calendar.clear();/*ww w. j av a 2 s. c o m*/ calendar.set(year, month, 1); }
From source file:Main.java
/** * Set the provided calendar to the first day of the month. Also clears all time information. * * @param calendar {@linkplain Calendar} to modify to be at the first fay of the month */// www . j a v a 2 s . co m public static void setToFirstDay(Calendar calendar) { int year = getYear(calendar); int month = getMonth(calendar); calendar.clear(); calendar.set(year, month, 1); }
From source file:Main.java
public static Date getEndFinanacialDate(Date taxdate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(taxdate);// w w w .java 2 s .c o m int yr = calendar.get(Calendar.YEAR); calendar.set(yr, 11, 31); taxdate = calendar.getTime(); return taxdate; }
From source file:Main.java
public static Date getFinanacialDate(Date taxdate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(taxdate);/* w ww.j a v a 2 s .com*/ int yr = calendar.get(Calendar.YEAR); calendar.set(yr, 00, 01); taxdate = calendar.getTime(); return taxdate; }
From source file:Main.java
public static void copyTo(Calendar from, Calendar to) { int year = from.get(Calendar.YEAR); int month = from.get(Calendar.MONTH); int day = from.get(Calendar.DAY_OF_MONTH); to.set(year, month, day); to.getTimeInMillis();//from w ww. ja v a 2 s . c o m }