List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static Date getDateFromLong(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time);//from ww w. j a v a 2 s.c o m return cal.getTime(); }
From source file:Main.java
public static boolean isCurrentDate(Calendar comparedDate) { Calendar cal = Calendar.getInstance(); int[] comparedElements = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH }; for (int elem : comparedElements) { if (cal.get(elem) != comparedDate.get(elem)) { return false; }// w w w . j av a2 s . co m } return true; }
From source file:Main.java
public static Date getFirstDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//w w w .j a v a 2 s . c om calendar.set(Calendar.DATE, 1); return calendar.getTime(); }
From source file:Main.java
public static Calendar getCurrentDate() { Calendar currentDate = Calendar.getInstance(); currentDate.setTime(new Date()); return currentDate; }
From source file:Main.java
public static Calendar DateToCalendar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; }
From source file:Main.java
public static int getMonthOfYear(Date time) { Calendar calendar = Calendar.getInstance(); calendar.setTime(time);//from w ww.jav a2 s.c o m return calendar.get(Calendar.MONTH); }
From source file:Main.java
public static long timeInMillis(int hour, int minute) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, 0); long timeBefore = calendar.getTimeInMillis(); if (Calendar.getInstance().getTimeInMillis() > timeBefore) calendar.add(Calendar.DAY_OF_WEEK, 1); return calendar.getTimeInMillis(); }
From source file:Main.java
public static String getBackupFileName() { Calendar c = Calendar.getInstance(); SimpleDateFormat format1 = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss"); return format1.format(c.getTime()) + ".txt"; }
From source file:Main.java
@Deprecated public static int getMonthOfMonth(int y, int m) { Calendar calendar = Calendar.getInstance(); calendar.set(y, m - 1, 1);//from w w w . j a v a2 s . co m int month = calendar.get(Calendar.MONTH); return month + 1; }
From source file:Main.java
private static int getYearOfBirth(Date dateOfBirth) { Calendar dob = Calendar.getInstance(); dob.setTime(dateOfBirth);/*from w ww. j a v a2 s . c o m*/ return dob.get(Calendar.YEAR); }