List of usage examples for java.util Calendar setTime
public final void setTime(Date date)
Date
. From source file:Main.java
public static int getMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.MONTH) + 1; }
From source file:Main.java
private static int getYearOfBirth(Date dateOfBirth) { Calendar dob = Calendar.getInstance(); dob.setTime(dateOfBirth); return dob.get(Calendar.YEAR); }
From source file:Main.java
public static int[] getYMD(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return new int[] { cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DATE) }; }
From source file:Main.java
public static Calendar DateToCalendar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal;/* w w w. jav a 2s . com*/ }
From source file:Main.java
static Calendar parseDateString(final String format, final String date) throws ParseException { final Date parsed = new SimpleDateFormat(format).parse(date); final Calendar cal = Calendar.getInstance(); cal.setTime(parsed); return cal;/*from w ww . ja v a2 s. co m*/ }
From source file:Main.java
public static Integer GetDayOfMonth(Date d) { Calendar cal = Calendar.getInstance(); cal.setTime(d); return cal.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getDayOfMonth() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.DAY_OF_MONTH); return year;// ww w . ja v a2 s. co m }
From source file:Main.java
public static String getSecond() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int second = c.get(Calendar.SECOND); return Integer.toString(second); }
From source file:Main.java
public static Calendar getCalendarFromDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal;// w w w .j a va2s . c om }
From source file:Main.java
public static int gettimeinhours(long t) { Calendar c = new GregorianCalendar(); c.setTime(new Date(t)); return c.get(Calendar.HOUR_OF_DAY); }