List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static String getCurrentTimeStampYYYY_MM_DD_HH_MM_SS() { Calendar cal = new GregorianCalendar(); return makeTimeString(cal.get(Calendar.YEAR), 4) + "/" + makeTimeString(cal.get(Calendar.MONTH) + 1, 2) + "/" + makeTimeString(cal.get(Calendar.DAY_OF_MONTH), 2) + " " + makeTimeString(cal.get(Calendar.HOUR_OF_DAY), 2) + ":" + makeTimeString(cal.get(Calendar.MINUTE), 2) + ":" + makeTimeString(cal.get(Calendar.SECOND), 2); }
From source file:Main.java
public static int getWeekOfDateDecimal(Date dt) { int[] weekDays = { 6, 0, 1, 2, 3, 4, 5 }; Calendar cal = Calendar.getInstance(); cal.setTime(dt);/*from w ww .j a v a 2 s . c o m*/ int w = cal.get(Calendar.DAY_OF_WEEK) - 1; if (w < 0) w = 0; return weekDays[w]; }
From source file:Main.java
public static String getCurrentTimeStamp() { Calendar cal = new GregorianCalendar(); return makeTimeString(cal.get(Calendar.DAY_OF_MONTH), 2) + "." + makeTimeString(cal.get(Calendar.MONTH) + 1, 2) + "." + makeTimeString(cal.get(Calendar.YEAR), 4) + " " + makeTimeString(cal.get(Calendar.HOUR_OF_DAY), 2) + ":" + makeTimeString(cal.get(Calendar.MINUTE), 2) + ":" + makeTimeString(cal.get(Calendar.SECOND), 2); }
From source file:Main.java
public static int getHour() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int hour = c.get(Calendar.HOUR_OF_DAY); return hour;/*from ww w . ja va 2 s .c o m*/ }
From source file:Main.java
public static int getDayWeek(int index) { int year = MIN_YEAR + index / 12; int month = index % 12; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar date = new GregorianCalendar(year, month, 1); int dayweek = date.get(Calendar.DAY_OF_WEEK); return dayweek; }
From source file:Main.java
public static boolean isSameDayHour(Calendar cal1, Calendar cal2) { return (isSameDay(cal1, cal2) && (cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY))); }
From source file:Main.java
public static int getMonth() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.MONTH); return year;//from w ww. ja v a 2s . c om }
From source file:Main.java
public static int getWeekday(long time) { Calendar min = Calendar.getInstance(); min.setTimeInMillis(time);//from w ww.j av a 2 s . co m return min.get(Calendar.DAY_OF_WEEK); }
From source file:Main.java
public static int getDayOfYear() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.DAY_OF_YEAR); return year;//from ww w . jav a2 s .co m }
From source file:Main.java
public static boolean isBefore(Calendar currentCalendar, Calendar max) { int currentYear = currentCalendar.get(Calendar.YEAR); int currentMonth = currentCalendar.get(Calendar.MONTH); int currentDay = currentCalendar.get(Calendar.DAY_OF_MONTH); int maxYear = max.get(Calendar.YEAR); int maxMonth = max.get(Calendar.MONTH); int maxDay = max.get(Calendar.DAY_OF_MONTH); Log.i("TAG",/*w w w . ja va 2 s .c om*/ (currentYear <= maxYear && currentMonth <= maxMonth && currentDay <= maxDay) + "currentYear" + currentYear + "maxYear" + maxYear + "currentMonth" + currentMonth + "maxMonth" + maxMonth + "currentDay" + currentDay + "maxDay" + maxDay); return (currentYear == maxYear) ? ((currentMonth == currentMonth) ? (currentDay < maxDay) : (currentMonth < maxMonth)) : (currentYear < maxYear); }