List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static void copyTo(Calendar from, Calendar to) { int year = from.get(Calendar.YEAR); int month = from.get(Calendar.MONTH); int day = from.get(Calendar.DAY_OF_MONTH); to.set(year, month, day);//from ww w .j a v a2 s . co m to.getTimeInMillis(); }
From source file:Main.java
public static int GetMonth() { Calendar now = Calendar.getInstance(); return now.get(Calendar.MONTH); }
From source file:Main.java
private static boolean isSameDay(Calendar now, Calendar msg) { int nowDay = now.get(Calendar.DAY_OF_YEAR); int msgDay = msg.get(Calendar.DAY_OF_YEAR); return nowDay == msgDay; }
From source file:Main.java
public static int GetMonth() { Calendar now = Calendar.getInstance(); return now.get(Calendar.MONTH) + 1; }
From source file:Main.java
/** * Return if the two calendar is in the same day, ignoring time * @param day1/*from w w w. j av a 2 s . co m*/ * @param day2 * @return */ public static boolean isSameDay(Calendar day1, Calendar day2) { return day1.get(Calendar.YEAR) == day2.get(Calendar.YEAR) && day1.get(Calendar.MONTH) == day2.get(Calendar.MONTH) && day1.get(Calendar.DAY_OF_MONTH) == day2.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
/** * Checks the calendar is today.//w ww . j a v a2s . c om * @param calendar Calendar object to check. * @return true if calendar is today else false. */ public static boolean isToday(Calendar calendar) { return calendar.get(Calendar.MONTH) == Calendar.getInstance().get(Calendar.MONTH) && calendar.get(Calendar.DAY_OF_MONTH) == Calendar.getInstance().get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static String getCurrentData() { Calendar c = Calendar.getInstance(); return "" + c.get(Calendar.YEAR) + c.get(Calendar.MONTH) + c.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int currentDay() { Calendar c = Calendar.getInstance(); int day = c.get(Calendar.DATE); return day;// w w w . j ava 2 s .c o m }
From source file:Main.java
@SuppressLint("DefaultLocale") public static void SaveLastWallpaperDate(Context context, Calendar dateTime) { int year = dateTime.get(Calendar.YEAR); int month = dateTime.get(Calendar.MONTH); int date = dateTime.get(Calendar.DATE); String dateTimeToString = String.format("%d/%d/%d", year, month, date); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferences.edit().putString("wallpaper_date", dateTimeToString).commit(); }
From source file:Main.java
/** * Checks the calendar is tomorrow./*from ww w . j a va 2s . co m*/ * @param calendar Calendar object to check. * @return true if calendar is tomorrow else false. */ public static boolean isTomorrow(Calendar calendar) { return calendar.get(Calendar.MONTH) == Calendar.getInstance().get(Calendar.MONTH) && calendar.get(Calendar.DAY_OF_MONTH) == (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + 1); }