List of usage examples for java.util Calendar setTime
public final void setTime(Date date)
Date
. From source file:Main.java
public static int getNumberOfDaysInMonth(Date someDayInMonth) { Calendar monthCal = Calendar.getInstance(); monthCal.setTime(someDayInMonth); return monthCal.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static Date addFiveMinutes(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.MINUTE, 5);//from ww w . j a va 2 s .c om return cal.getTime(); }
From source file:Main.java
public static Date addHours(Date date, int hours) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.HOUR_OF_DAY, hours); return cal.getTime(); }
From source file:Main.java
public static int getMonthOfYear(Date time) { Calendar calendar = Calendar.getInstance(); calendar.setTime(time); return calendar.get(Calendar.MONTH); }
From source file:Main.java
public static Calendar getCalendar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal;// w w w . j a va 2s . c o m }
From source file:Main.java
private static Calendar buildFromDate(Date from) { Calendar c = Calendar.getInstance(); c.setTime(from); return c;//from ww w .j a va2 s . c o m }
From source file:Main.java
public static String dateformat(String format, Date date, int afterDay) { Calendar ca = Calendar.getInstance(); ca.setTime(date); if (afterDay != 0) ca.add(Calendar.DATE, afterDay); SimpleDateFormat df = new SimpleDateFormat(format); return df.format(ca.getTime()); }
From source file:Main.java
public static Date dateAddDays(Date date, int days) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_YEAR, days); return cal.getTime(); }
From source file:Main.java
public static Calendar dateToCalendar(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; }
From source file:Main.java
public static Calendar dateToCalendar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal;// w w w.j ava 2 s .c o m }