List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static int getCurrentDayOfMonthFromTimestamp() { Calendar currentTime = Calendar.getInstance(); return currentTime.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int timeZoneOffset() { Calendar cal = Calendar.getInstance(); int offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / (60 * 1000); return offset; }
From source file:Main.java
public static String getDay() { Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_MONTH); return Integer.toString(day); }
From source file:Main.java
static public int getSecond() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.SECOND); }
From source file:Main.java
public static boolean isSameDate(Calendar calendar1, Calendar calendar2) { if (calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH)) { return true; } else {//w ww. j a v a 2 s. c o m return false; } }
From source file:Main.java
public static String getCurrentTime() { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); String time = year + "-" + month + "-" + day; return time;/*from ww w.jav a 2 s. c o m*/ }
From source file:Main.java
public static int getIsFristWeek() { Calendar cal = Calendar.getInstance(); int date = cal.get(Calendar.DAY_OF_WEEK); Log.e("WeekDay", "" + date); return date;/*ww w . j av a 2 s . c om*/ }
From source file:Main.java
public static boolean isDay() { Calendar calendar = Calendar.getInstance(); int time = calendar.get(Calendar.HOUR_OF_DAY); return time >= 6 && time < 18; }
From source file:Main.java
public static String getStringTime() { Calendar c = Calendar.getInstance(Locale.ITALY); return c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); }
From source file:Main.java
public static Calendar getMorningCal(int hour, int minute) { Calendar c = Calendar.getInstance(); if (c.get(Calendar.HOUR_OF_DAY) > 3) { //next day c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) + 1); }//from ww w.j a va2 s . com c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, 0); return c; }