List of usage examples for android.text.format Time set
public void set(Time that)
From source file:Main.java
public static String getFormat3339ByDate(Date date, boolean isallDay) { Time time = new Time(); time.set(date.getTime()); return time.format3339(isallDay); }
From source file:Main.java
/** * Transform a long representation of a Date into Time * @param dateLong: date in milliseconds from epoch * @return time representing the date// w ww . jav a 2 s . c om */ public static Time longToTime(long dateLong) { Time time = new Time(); time.set(dateLong); return time; }
From source file:Main.java
private static int getIntervalInDays(long startMillis, long endMillis, Time timeObj) { timeObj.set(startMillis); int startDay = Time.getJulianDay(startMillis, timeObj.gmtoff); timeObj.set(endMillis);/*w ww. j a v a 2 s . co m*/ return Time.getJulianDay(endMillis, timeObj.gmtoff) - startDay; }
From source file:Main.java
public static long getNumberOfDaysPassed(long date1, long date2) { Time sThenTime = new Time(); sThenTime.set(date1); int day1 = Time.getJulianDay(date1, sThenTime.gmtoff); sThenTime.set(date2);//from w w w . ja va 2s . c om int day2 = Time.getJulianDay(date2, sThenTime.gmtoff); return Math.abs(day2 - day1); }
From source file:Main.java
public static boolean isThisYear(long when) { Time time = new Time(); time.set(when); int thenYear = time.year; // int thenMonth = time.month; int thenMonthDay = time.monthDay; time.set(System.currentTimeMillis()); return (thenYear == time.year) && (thenMonthDay != time.monthDay); }
From source file:Main.java
private static boolean isTomorrow(long when) { Time time = new Time(); time.set(when); int thenYear = time.year; int thenMonth = time.month; int thenMonthDay = time.monthDay; thenMonthDay--;// w ww. j av a 2 s . com time.setToNow(); return (thenYear == time.year) && (thenMonth == time.month) && (thenMonthDay == time.monthDay); }
From source file:Main.java
public static String getTimeAndDate(long j) { try {/* www. ja v a2s. c o m*/ Calendar instance = Calendar.getInstance(); TimeZone timeZone = TimeZone.getDefault(); instance.setTimeInMillis(j); instance.add(14, timeZone.getOffset(instance.getTimeInMillis())); String format = new SimpleDateFormat(" dd, MMM yyyy").format(instance.getTime()); Time time = new Time(); time.set(j); return time.format("%H:%M") + format; } catch (Exception e) { return ""; } }
From source file:Main.java
public static boolean isMorning(long when) { android.text.format.Time time = new android.text.format.Time(); time.set(when); int hour = time.hour; return (hour >= 0) && (hour < 12); }
From source file:Main.java
/** * Determine the difference, in days between two dates. Uses similar logic as the * {@link android.text.format.DateUtils.getRelativeTimeSpanString} method. * * @param time Instance of time object to use for calculations. * @param date1 First date to check./*from www. j av a 2s .c o m*/ * @param date2 Second date to check. * @return The absolute difference in days between the two dates. */ public static int getDayDifference(Time time, long date1, long date2) { time.set(date1); int startDay = Time.getJulianDay(date1, time.gmtoff); time.set(date2); int currentDay = Time.getJulianDay(date2, time.gmtoff); return Math.abs(currentDay - startDay); }
From source file:Main.java
public static boolean isCurrentYear(long when) { android.text.format.Time time = new android.text.format.Time(); time.set(when); int thenYear = time.year; time.set(System.currentTimeMillis()); return (thenYear == time.year); }