android.text.format.Time

Here are the examples of the java api class android.text.format.Time taken from open source projects.

1. TimeHelper#get3339DaysFromToday()

Project: NotePad
File: TimeHelper.java
/**
	 * Given the argument i, will return todays date + i days, formatted as
	 * RFC3339 in UTC time zone
	 */
public static String get3339DaysFromToday(int i) {
    Time localtime = new Time(Time.getCurrentTimezone());
    localtime.setToNow();
    int julianToday = Time.getJulianDay(localtime.toMillis(false), localtime.gmtoff);
    Time time = new Time(Time.TIMEZONE_UTC);
    time.setJulianDay(julianToday + i);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    Log.d("dragdate", "" + i + " days ago: " + time.format3339(false));
    return time.format3339(false);
}

2. MessageUtils#formatTimeString()

Project: androidclient
File: MessageUtils.java
public static String formatTimeString(Context context, long when) {
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();
    // Basic settings for formatDateTime() we want for all cases.
    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM | DateUtils.FORMAT_SHOW_TIME;
    return DateUtils.formatDateTime(context, when, format_flags);
}

3. MessageUtils#formatDateString()

Project: androidclient
File: MessageUtils.java
public static String formatDateString(Context context, long when) {
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();
    // Basic settings for formatDateTime() we want for all cases.
    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_CAP_AMPM;
    // If the message is from a different year, show the date and year.
    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        // If it is from a different day than today, show only the date.
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    }
    return DateUtils.formatDateTime(context, when, format_flags);
}

4. CalendarQueryService#onHandleIntent()

Project: AndroidWearable-Samples
File: CalendarQueryService.java
@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    // Query calendar events in the next 24 hours.
    Time time = new Time();
    time.setToNow();
    long beginTime = time.toMillis(true);
    time.monthDay++;
    time.normalize(true);
    long endTime = time.normalize(true);
    List<Event> events = queryEvents(this, beginTime, endTime);
    for (Event event : events) {
        final PutDataMapRequest putDataMapRequest = event.toPutDataMapRequest();
        if (mGoogleApiClient.isConnected()) {
            Wearable.DataApi.putDataItem(mGoogleApiClient, putDataMapRequest.asPutDataRequest()).await();
        } else {
            Log.e(TAG, "Failed to send data item: " + putDataMapRequest + " - Client disconnected from Google Play Services");
        }
    }
    mGoogleApiClient.disconnect();
}

5. Utility#getDayName()

Project: UdacityAndroidWear
File: Utility.java
/**
     * Given a day, returns just the name to use for that day.
     * E.g "today", "tomorrow", "wednesday".
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return
     */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.
    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}

6. Utility#getDayName()

Project: Sunshine-Version-2
File: Utility.java
/**
     * Given a day, returns just the name to use for that day.
     * E.g "today", "tomorrow", "wednesday".
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return
     */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.
    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}

7. MainActivity#onPositionChanged()

Project: ScrollBarPanelWithClock
File: MainActivity.java
@Override
public void onPositionChanged(ExtendedListView listView, int position, View scrollBarPanel) {
    Clock analogClockObj = (Clock) scrollBarPanel.findViewById(R.id.analogClockScroller);
    TextView tv = (TextView) scrollBarPanel.findViewById(R.id.timeTextView);
    tv.setText("" + position);
    Time timeObj = new Time();
    analogClockObj.setSecondHandVisibility(false);
    analogClockObj.setVisibility(View.VISIBLE);
    timeObj.set(position + 3, position, 5, 0, 0, 0);
    analogClockObj.onTimeChanged(timeObj);
}

8. DateView#toDate()

Project: NotePad
File: DateView.java
public static CharSequence toDate(final Context context, String time3339) {
    // TODO remove this
    Time time = new Time(Time.getCurrentTimezone());
    time.parse3339(time3339);
    // Ugg... Not beautiful... :-(
    String dateFormatMicro = "MMM d";
    String dateFormatForRes = context.getString(R.string.dateformat_micro);
    if (dateFormatForRes != null) {
        dateFormatMicro = dateFormatForRes;
    }
    return toDate(dateFormatMicro, time.toMillis(false));
}

9. LoadConfig#initConfig()

Project: Introspy-Android
File: LoadConfig.java
// no config file means the app won't be hooked
public Boolean initConfig(String dataDir) {
    if (_alreadyChecked)
        return _previousCheckValue;
    Time now = new Time();
    now.setToNow();
    // check for modifications only every X
    if (_lastCheck.toMillis(true) + 3000 >= now.toMillis(true)) {
        return _previousCheckValue;
    }
    String path = dataDir + "/" + _configFileName;
    _hookTypes = readFirstLineOfFile(path);
    if (_onlyCheckOnce)
        _alreadyChecked = true;
    _lastCheck.setToNow();
    if (_hookTypes.isEmpty()) {
        return (_previousCheckValue = false);
    }
    return (_previousCheckValue = true);
}

10. Utility#getDayName()

Project: forecast
File: Utility.java
/**
     * Given a day, returns just the name to use for that day.
     * E.g "today", "tomorrow", "wednesday".
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return
     */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.
    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}

11. DateTimePickerDialog#onTimeChanged()

Project: chromium_webview
File: DateTimePickerDialog.java
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
    Time time = new Time();
    time.set(0, mTimePicker.getCurrentMinute(), mTimePicker.getCurrentHour(), mDatePicker.getDayOfMonth(), mDatePicker.getMonth(), mDatePicker.getYear());
    if (time.toMillis(true) < mMinTimeMillis) {
        time.set(mMinTimeMillis);
    } else if (time.toMillis(true) > mMaxTimeMillis) {
        time.set(mMaxTimeMillis);
    }
    mTimePicker.setCurrentHour(time.hour);
    mTimePicker.setCurrentMinute(time.minute);
}

12. PushReportUtility#getNowTime()

Project: appcan-android
File: PushReportUtility.java
public static String getNowTime() {
    Time time = new Time();
    time.setToNow();
    int year = time.year;
    int month = time.month + 1;
    int day = time.monthDay;
    int minute = time.minute;
    int hour = time.hour;
    int sec = time.second;
    return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + sec;
}

13. Utility#getDayName()

Project: Angani
File: Utility.java
/**
     * Given a day, returns just the name to use for that day.
     * E.g "today", "tomorrow", "wednesday".
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return
     */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.
    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}

14. Utility#getDayName()

Project: Advanced_Android_Development
File: Utility.java
/**
     * Given a day, returns just the name to use for that day.
     * E.g "today", "tomorrow", "wednesday".
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return
     */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.
    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}

15. TimeHelper#dateBefore()

Project: NotePad
File: TimeHelper.java
public static boolean dateBefore(final String itemDate, final String referenceDate) {
    // Fix for timezone issue. We don't care about them
    // A date like 2013-03-05T00:00 will be abbreviated
    // to 2013-03-05
    String dbstring = itemDate;
    if (dbstring.contains("T")) {
        dbstring = dbstring.substring(0, dbstring.indexOf("T"));
    }
    String compareString = referenceDate;
    if (compareString.contains("T")) {
        compareString = compareString.substring(0, compareString.indexOf("T"));
    }
    Time time = new Time();
    time.parse3339(dbstring);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    Time ctime = new Time();
    ctime.parse3339(compareString);
    return time.before(ctime);
}

16. MessageUtils#formatTimeStampString()

Project: qksms
File: MessageUtils.java
public static String formatTimeStampString(Context context, long when, boolean fullFormat) {
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();
    // Basic settings for formatDateTime() we want for all cases.
    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM;
    // If the message is from a different year, show the date and year.
    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        // If it is from a different day than today, show only the date.
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        // Otherwise, if the message is from today, show the time.
        format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }
    // the year only happen if it is a different year from today).
    if (fullFormat) {
        format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
    }
    return DateUtils.formatDateTime(context, when, format_flags);
}

17. NetworkPolicyManager#computeNextCycleBoundary()

Project: qksms
File: NetworkPolicyManager.java
/**
     * {@hide}
     */
public static long computeNextCycleBoundary(long currentTime, NetworkPolicy policy) {
    if (policy.cycleDay == CYCLE_NONE) {
        throw new IllegalArgumentException("Unable to compute boundary without cycleDay");
    }
    final Time now = new Time(policy.cycleTimezone);
    now.set(currentTime);
    // first, find cycle boundary for current month
    final Time cycle = new Time(now);
    cycle.hour = cycle.minute = cycle.second = 0;
    snapToCycleDay(cycle, policy.cycleDay);
    if (Time.compare(cycle, now) <= 0) {
        // cycle boundary is before now, use next cycle boundary; start by
        // pushing ourselves squarely into next month.
        final Time nextMonth = new Time(now);
        nextMonth.hour = nextMonth.minute = nextMonth.second = 0;
        nextMonth.monthDay = 1;
        nextMonth.month += 1;
        nextMonth.normalize(true);
        cycle.set(nextMonth);
        snapToCycleDay(cycle, policy.cycleDay);
    }
    return cycle.toMillis(true);
}

18. NetworkPolicyManager#computeLastCycleBoundary()

Project: qksms
File: NetworkPolicyManager.java
/**
     * Compute the last cycle boundary for the given {@link NetworkPolicy}. For
     * example, if cycle day is 20th, and today is June 15th, it will return May
     * 20th. When cycle day doesn't exist in current month, it snaps to the 1st
     * of following month.
     *
     * @hide
     */
public static long computeLastCycleBoundary(long currentTime, NetworkPolicy policy) {
    if (policy.cycleDay == CYCLE_NONE) {
        throw new IllegalArgumentException("Unable to compute boundary without cycleDay");
    }
    final Time now = new Time(policy.cycleTimezone);
    now.set(currentTime);
    // first, find cycle boundary for current month
    final Time cycle = new Time(now);
    cycle.hour = cycle.minute = cycle.second = 0;
    snapToCycleDay(cycle, policy.cycleDay);
    if (Time.compare(cycle, now) >= 0) {
        // cycle boundary is beyond now, use last cycle boundary; start by
        // pushing ourselves squarely into last month.
        final Time lastMonth = new Time(now);
        lastMonth.hour = lastMonth.minute = lastMonth.second = 0;
        lastMonth.monthDay = 1;
        lastMonth.month -= 1;
        lastMonth.normalize(true);
        cycle.set(lastMonth);
        snapToCycleDay(cycle, policy.cycleDay);
    }
    return cycle.toMillis(true);
}

19. TimeHelper#dateIs()

Project: NotePad
File: TimeHelper.java
public static boolean dateIs(final String itemDate, final String referenceDate) {
    // Fix for timezone issue. We don't care about them
    // A date like 2013-03-05T00:00 will be abbreviated
    // to 2013-03-05
    String dbstring = itemDate;
    if (dbstring.contains("T")) {
        dbstring = dbstring.substring(0, dbstring.indexOf("T"));
    }
    String compareString = referenceDate;
    if (compareString.contains("T")) {
        compareString = compareString.substring(0, compareString.indexOf("T"));
    }
    Time time = new Time();
    time.parse3339(dbstring);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    Time ctime = new Time();
    ctime.parse3339(compareString);
    return (time.year == ctime.year) && (time.month == ctime.month) && (time.monthDay == ctime.monthDay);
}

20. TimeHelper#milli7DaysAgoLong()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-23
	 */
public static long milli7DaysAgoLong() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday - 7);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return time.toMillis(false);
}

21. TimeHelper#milliYesterdayStartLong()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-29 00:00:00
	 */
public static long milliYesterdayStartLong() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday - 1);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return time.toMillis(false);
}

22. TimeHelper#dateEightDay()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-01-01 Returns 2012-01-08
	 */
public static String dateEightDay() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday + 8);
    return time.format(dateFormat);
}

23. TimeHelper#dateTomorrow()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-31
	 */
public static String dateTomorrow() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday + 1);
    return time.format(dateFormat);
}

24. MessageUtils#formatTimeStampString()

Project: androidclient
File: MessageUtils.java
public static String formatTimeStampString(Context context, long when, boolean fullFormat) {
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();
    // Basic settings for formatDateTime() we want for all cases.
    int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM;
    // If the message is from a different year, show the date and year.
    if (then.year != now.year) {
        format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        // If it is from a different day than today, show only the date.
        format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        // Otherwise, if the message is from today, show the time.
        format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }
    // the year only happen if it is a different year from today).
    if (fullFormat) {
        format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
    }
    return DateUtils.formatDateTime(context, when, format_flags);
}

25. WeatherContract#normalizeDate()

Project: UdacityAndroidWear
File: WeatherContract.java
// To make it easy to query for the exact date, we normalize all dates that go into
// the database to the start of the the Julian day at UTC.
public static long normalizeDate(long startDate) {
    // normalize the start date to the beginning of the (UTC) day
    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
}

26. WeatherContract#normalizeDate()

Project: Sunshine-Version-2
File: WeatherContract.java
// To make it easy to query for the exact date, we normalize all dates that go into
// the database to the start of the the Julian day at UTC.
public static long normalizeDate(long startDate) {
    // normalize the start date to the beginning of the (UTC) day
    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
}

27. TimeHelper#milli7DaysAgo()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-23
	 */
public static String milli7DaysAgo() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday - 7);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return Long.toString(time.toMillis(false));
}

28. TimeHelper#milliYesterdayStart()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-29 00:00:00
	 */
public static String milliYesterdayStart() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    int julianToday = Time.getJulianDay(time.toMillis(false), time.gmtoff);
    time.setJulianDay(julianToday - 1);
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return Long.toString(time.toMillis(false));
}

29. TimeHelper#milliTodayStartLong()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-30 00:00:00
	 */
public static long milliTodayStartLong() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return time.toMillis(false);
}

30. TimeHelper#dateToday()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-30
	 */
public static String dateToday() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    return time.format(dateFormat);
}

31. ParserUtils#parseTime()

Project: iosched
File: ParserUtils.java
/**
     * Parse the given string as a RFC 3339 timestamp, returning the value as
     * milliseconds since the epoch.
     */
public static long parseTime(String timestamp) {
    final Time time = new Time();
    time.parse3339(timestamp);
    return time.toMillis(false);
}

32. ForecastContract#normalizeDate()

Project: forecast
File: ForecastContract.java
// To make it easy to query for the exact date, we normalize all dates that go into
// the database to the start of the the Julian day at UTC.
public static long normalizeDate(long startDate) {
    // normalize the start date to the beginning of the (UTC) day
    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
}

33. LocalLib#getTimeStamp()

Project: Cafe
File: LocalLib.java
private static String getTimeStamp() {
    Time localTime = new Time("Asia/Hong_Kong");
    localTime.setToNow();
    return localTime.format("%Y-%m-%d_%H-%M-%S");
}

34. WeatherContract#normalizeDate()

Project: Advanced_Android_Development
File: WeatherContract.java
// To make it easy to query for the exact date, we normalize all dates that go into
// the database to the start of the the Julian day at UTC.
public static long normalizeDate(long startDate) {
    // normalize the start date to the beginning of the (UTC) day
    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
}

35. WeatherDetailsView#setWeatherInfo()

Project: WayHoo
File: WeatherDetailsView.java
public void setWeatherInfo(RealTime realTime) {
    if (realTime == null || realTime.getAnimation_type() < 0)
        return;
    // ??
    mLunarCalendar = new LunarCalendar(getContext());
    Time time = new Time();
    time.set(System.currentTimeMillis());
    LunarCalendarConvertUtil.parseLunarCalendar(time.year, time.month, time.monthDay, mLunarCalendar);
    // ????
    detailsWeatherIV.setImageResource(WeatherIconUtils.getWeatherIcon(realTime.getAnimation_type()));
    weatherNameTV.setText(realTime.getWeather_name());
    feelsTempTV.setText(realTime.getTemp() + "°");
    humidityTV.setText(realTime.getHumidity() + "%");
    String[] winds = realTime.getWind().split("?");
    if (winds.length > 1) {
        windTV.setText(winds[1]);
        windDescTV.setText(winds[0]);
    } else {
        windTV.setText(realTime.getWind());
    }
    // detailsFootTV.setText("?????");
    // detailsFootTV.setText(mLunarCalendar.getLunarDayInfo());
    String str[] = mLunarCalendar.getLunarCalendarInfo(false);
    detailsFootTV.setText(mLunarCalendar.getLunarYear(mLunarCalendar.lunarYear) + "(" + mLunarCalendar.animalsYear(mLunarCalendar.lunarYear) + ")?" + str[1] + str[2]);
}

36. MonthView#setMonthParams()

Project: uhabits
File: MonthView.java
/**
     * Sets all the parameters for displaying this week. The only required
     * parameter is the week number. Other parameters have a default value and
     * will only update if a new value is included, except for focus month,
     * which will always default to no focus month if no value is passed in. See
     * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
     *
     * @param params A map of the new parameters, see
     *            {@link #VIEW_PARAMS_HEIGHT}
     */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

37. Utility#getFormattedMonthDay()

Project: UdacityAndroidWear
File: Utility.java
/**
     * Converts db date format to the format "Month day", e.g "June 24".
     * @param context Context to use for resource localization
     * @param dateInMillis The db formatted date string, expected to be of the form specified
     *                in Utility.DATE_FORMAT
     * @return The day in the form of a string formatted "December 6"
     */
public static String getFormattedMonthDay(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
    SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
    String monthDayString = monthDayFormat.format(dateInMillis);
    return monthDayString;
}

38. Utility#getFriendlyDayString()

Project: UdacityAndroidWear
File: Utility.java
/**
     * Helper method to convert the database representation of the date into something to display
     * to users.  As classy and polished a user experience as "20140102" is, we can do better.
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return a user-friendly representation of the date.
     */
public static String getFriendlyDayString(Context context, long dateInMillis, boolean displayLongToday) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"
    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);
    // is "Today, June 24"
    if (displayLongToday && julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}

39. Utility#getFormattedMonthDay()

Project: Sunshine-Version-2
File: Utility.java
/**
     * Converts db date format to the format "Month day", e.g "June 24".
     * @param context Context to use for resource localization
     * @param dateInMillis The db formatted date string, expected to be of the form specified
     *                in Utility.DATE_FORMAT
     * @return The day in the form of a string formatted "December 6"
     */
public static String getFormattedMonthDay(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
    SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
    String monthDayString = monthDayFormat.format(dateInMillis);
    return monthDayString;
}

40. Utility#getFriendlyDayString()

Project: Sunshine-Version-2
File: Utility.java
/**
     * Helper method to convert the database representation of the date into something to display
     * to users.  As classy and polished a user experience as "20140102" is, we can do better.
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return a user-friendly representation of the date.
     */
public static String getFriendlyDayString(Context context, long dateInMillis) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"
    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);
    // is "Today, June 24"
    if (julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}

41. DateTimeUtils#parse3339()

Project: Qiitanium
File: DateTimeUtils.java
public static Date parse3339(String time) {
    final Time t = new Time();
    t.parse3339(time);
    return new Date(t.toMillis(false));
}

42. MonthView#setMonthParams()

Project: NotePad
File: MonthView.java
/**
     * Sets all the parameters for displaying this week. The only required
     * parameter is the week number. Other parameters have a default value and
     * will only update if a new value is included, except for focus month,
     * which will always default to no focus month if no value is passed in. See
     * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
     *
     * @param params A map of the new parameters, see
     *            {@link #VIEW_PARAMS_HEIGHT}
     */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

43. TimeHelper#milliTodayStart()

Project: NotePad
File: TimeHelper.java
/**
	 * Today = 2012-12-30 Returns 2012-12-30 00:00:00
	 */
public static String milliTodayStart() {
    Time time = new Time(Time.getCurrentTimezone());
    time.setToNow();
    time.hour = 0;
    time.minute = 0;
    time.second = 0;
    return Long.toString(time.toMillis(false));
}

44. Task#setAsCompleted()

Project: NotePad
File: Task.java
/**
	 * Set task as completed. Returns the time stamp that is set.
	 */
public Long setAsCompleted() {
    final Time time = new Time(Time.TIMEZONE_UTC);
    time.setToNow();
    completed = new Time().toMillis(false);
    return completed;
}

45. MonthView#setMonthParams()

Project: narrate-android
File: MonthView.java
/**
     * Sets all the parameters for displaying this week. The only required
     * parameter is the week number. Other parameters have a default value and
     * will only update if a new value is included, except for focus month,
     * which will always default to no focus month if no value is passed in. See
     * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
     *
     * @param params A map of the new parameters, see
     *               {@link #VIEW_PARAMS_HEIGHT}
     */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

46. TimeView#updateClock()

Project: LinLock
File: TimeView.java
protected void updateClock() {
    Time time = new Time();
    time.setToNow();
    int now = time.hour * 60 + time.minute;
    if (now != mLastTime) {
        setText(DateUtils.formatTime(getContext(), time.hour, time.minute));
        mLastTime = now;
    }
}

47. K9#isQuietTime()

Project: k-9
File: K9.java
public static boolean isQuietTime() {
    if (!mQuietTimeEnabled) {
        return false;
    }
    Time time = new Time();
    time.setToNow();
    Integer startHour = Integer.parseInt(mQuietTimeStarts.split(":")[0]);
    Integer startMinute = Integer.parseInt(mQuietTimeStarts.split(":")[1]);
    Integer endHour = Integer.parseInt(mQuietTimeEnds.split(":")[0]);
    Integer endMinute = Integer.parseInt(mQuietTimeEnds.split(":")[1]);
    Integer now = (time.hour * 60) + time.minute;
    Integer quietStarts = startHour * 60 + startMinute;
    Integer quietEnds = endHour * 60 + endMinute;
    // If start and end times are the same, we're never quiet
    if (quietStarts.equals(quietEnds)) {
        return false;
    }
    // 21:00 - 05:00 means we want to be quiet if it's after 9 or before 5
    if (quietStarts > quietEnds) {
        // if it's 22:00 or 03:00 but not 8:00
        if (now >= quietStarts || now <= quietEnds) {
            return true;
        }
    } else // 01:00 - 05:00
    {
        // if it' 2:00 or 4:00 but not 8:00 or 0:00
        if (now >= quietStarts && now <= quietEnds) {
            return true;
        }
    }
    return false;
}

48. ComicEditor#onTouchEvent()

Project: Ishusho
File: ComicEditor.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getPointerCount() == 1) {
        mStartDistance = 0.0f;
        if (/*getWidth() < getHeight() &&*/
        event.getX() > getWidth() - mModeIconSize && event.getX() < getWidth() && event.getY() > getHeight() - mModeIconSize && event.getY() < getHeight()) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                showModeSelect();
            }
        } else /*else if (getWidth() > getHeight() && event.getX() > getWidth() - mModeIconSize
					 && event.getX() < getWidth()
					 && event.getY() > 0
					 && event.getY() < mModeIconSize) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					showModeSelect();
				}
			}*/
        {
            if (mTouchMode == TouchModes.HAND)
                handleSingleTouchManipulateEvent(event);
            else if (mTouchMode == TouchModes.PENCIL || mTouchMode == TouchModes.LINE || mTouchMode == TouchModes.ERASER)
                handleSingleTouchDrawEvent(event);
            else if (mTouchMode == TouchModes.TEXT)
                handleSingleTouchTextEvent(event);
            else
                cancelLongPress();
        }
    } else {
        handleMultiTouchManipulateEvent(event);
    }
    Time t = new Time();
    t.setToNow();
    if (lastInvalidate != t) {
        invalidate();
        lastInvalidate = t;
    }
    super.onTouchEvent(event);
    return true;
}

49. SimpleMonthView#setMonthParams()

Project: HoloEverywhere
File: SimpleMonthView.java
/**
     * Sets all the parameters for displaying this week. The only required
     * parameter is the week number. Other parameters have a default value and
     * will only update if a new value is included, except for focus month,
     * which will always default to no focus month if no value is passed in. See
     * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
     *
     * @param params A map of the new parameters, see
     *               {@link #VIEW_PARAMS_HEIGHT}
     */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = DateTimePickerUtils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
    // Invalidate cached accessibility information.
    mNodeProvider.invalidateParent();
}

50. Utility#getFormattedMonthDay()

Project: forecast
File: Utility.java
/**
     * Converts db date format to the format "Month day", e.g "June 24".
     * @param context Context to use for resource localization
     * @param dateInMillis The db formatted date string, expected to be of the form specified
     *                in Utility.DATE_FORMAT
     * @return The day in the form of a string formatted "December 6"
     */
public static String getFormattedMonthDay(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
    SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
    String monthDayString = monthDayFormat.format(dateInMillis);
    return monthDayString;
}

51. Utility#getFriendlyDayString()

Project: forecast
File: Utility.java
/**
     * Helper method to convert the database representation of the date into something to display
     * to users.  As classy and polished a user experience as "20140102" is, we can do better.
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return a user-friendly representation of the date.
     */
public static String getFriendlyDayString(Context context, long dateInMillis) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"
    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);
    // is "Today, June 24"
    if (julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}

52. XListView#stopRefresh()

Project: Conquer
File: XListView.java
/**
	 * stop refresh, reset header view.
	 */
public void stopRefresh() {
    Time time = new Time();
    time.setToNow();
    mHeaderView.setRefreshTime(time.format("%Y-%m-%d %T"));
    if (mPullRefreshing == true) {
        mPullRefreshing = false;
        resetHeaderHeight();
    }
}

53. SimpleMonthView#setMonthParams()

Project: Conquer
File: SimpleMonthView.java
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
}

54. PushReportUtility#getCurYearAndMonth()

Project: appcan-android
File: PushReportUtility.java
public static String getCurYearAndMonth() {
    Time time = new Time();
    time.setToNow();
    int year = time.year;
    int month = time.month + 1;
    return year + "_" + month;
}

55. Utility#getFormattedMonthDay()

Project: Angani
File: Utility.java
/**
     * Converts db date format to the format "Month day", e.g "June 24".
     * @param context Context to use for resource localization
     * @param dateInMillis The db formatted date string, expected to be of the form specified
     *                in Utility.DATE_FORMAT
     * @return The day in the form of a string formatted "December 6"
     */
public static String getFormattedMonthDay(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
    SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
    String monthDayString = monthDayFormat.format(dateInMillis);
    return monthDayString;
}

56. Utility#getFriendlyDayString()

Project: Angani
File: Utility.java
/**
     * Helper method to convert the database representation of the date into something to display
     * to users.  As classy and polished a user experience as "20140102" is, we can do better.
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return a user-friendly representation of the date.
     */
public static String getFriendlyDayString(Context context, long dateInMillis) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"
    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);
    // is "Today, June 24"
    if (julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}

57. Utility#getFormattedMonthDay()

Project: Advanced_Android_Development
File: Utility.java
/**
     * Converts db date format to the format "Month day", e.g "June 24".
     * @param context Context to use for resource localization
     * @param dateInMillis The db formatted date string, expected to be of the form specified
     *                in Utility.DATE_FORMAT
     * @return The day in the form of a string formatted "December 6"
     */
public static String getFormattedMonthDay(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
    SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
    String monthDayString = monthDayFormat.format(dateInMillis);
    return monthDayString;
}

58. Utility#getFriendlyDayString()

Project: Advanced_Android_Development
File: Utility.java
/**
     * Helper method to convert the database representation of the date into something to display
     * to users.  As classy and polished a user experience as "20140102" is, we can do better.
     *
     * @param context Context to use for resource localization
     * @param dateInMillis The date in milliseconds
     * @return a user-friendly representation of the date.
     */
public static String getFriendlyDayString(Context context, long dateInMillis, boolean displayLongToday) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"
    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);
    // is "Today, June 24"
    if (displayLongToday && julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}

59. TimeView#updateClock()

Project: AcDisplay
File: TimeView.java
protected void updateClock() {
    Time time = new Time();
    time.setToNow();
    int now = time.hour * 60 + time.minute;
    if (now != mLastTime) {
        setText(DateUtils.formatTime(getContext(), time.hour, time.minute));
        mLastTime = now;
    }
}

60. InactiveTimeHelper#isInactiveTime()

Project: AcDisplay
File: InactiveTimeHelper.java
public static boolean isInactiveTime(Config config) {
    Time time = new Time();
    time.setToNow();
    int now = time.hour * 60 + time.minute;
    int from = config.getInactiveTimeFrom();
    int to = config.getInactiveTimeTo();
    return from < to ? now >= from && now <= to : now >= from || now <= to;
}