Android Time - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Time class.

This code example shows how to use the following methods:normalize, set, setJulianDay, toMillis
        } 
    } 
 
    @Test 
    public void testSetJulianDay() throws Exception { 
        Time time = new Time();
        time.set(0, 0, 0, 12, 5, 2008);
        time.timezone = "Australia/Sydney";
        long millis = time.normalize(true);
 
        int julianDay = Time.getJulianDay(millis, time.gmtoff);
        time.setJulianDay(julianDay);
 
        assertTrue(time.hour == 0 || time.hour == 1);
        assertEquals(0, time.minute);
        assertEquals(0, time.second);
 
        millis = time.toMillis(false);
        int day = Time.getJulianDay(millis, time.gmtoff);
 

8
CodeRank
This code example shows how to use the following methods:normalize, set
                int flags, String output) {
            if ((flags & DateUtils.FORMAT_UTC) != 0) {
                date1 = new Time(Time.TIMEZONE_UTC);
                date2 = new Time(Time.TIMEZONE_UTC);
            } else { 
                date1 = new Time();
                date2 = new Time();
            } 
 
            // If the year is zero, then set it to the current year. 
            if (year1 == 0 && year2 == 0) {
                date1.set(System.currentTimeMillis());
                year1 = year2 = date1.year;
            } 
 
            date1.set(0, minute1, hour1, day1, month1, year1);
            date1.normalize(true /* ignore isDst */);
 
            date2.set(0, minute2, hour2, day2, month2, year2);
            date2.normalize(true /* ignore isDst */);

7
CodeRank
This code example shows how to use the following methods:normalize, set, toMillis
import android.text.format.Time; 
 
class Utils { 
    public static long createTimeInMillis(int second, int minute, int hour, int monthDay,
            int month, int year, String timezone) {
        Time t = new Time(timezone);
        t.set(second, minute, hour, monthDay, month, year);
        t.normalize(false);
        return t.toMillis(false);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:set, toMillis
            year = 2038;
            month = Calendar.JANUARY;
            date = 1;
        } 
 
        Time time = new Time(Time.TIMEZONE_UTC);
        time.set(timeOfDay.second, timeOfDay.minute, timeOfDay.hour, date,
                month, year);
        return time.toMillis(false /* use isDst */);
    } 
 
    private static int getDate(String dateString) {
        if (dateString.length() == 2) {
            return (dateString.charAt(0) - '0') * 10
                    + (dateString.charAt(1) - '0');
        } else { 
            return (dateString.charAt(0) - '0');
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:compare, setJulianDay, toMillis
        } 
        // Selection is (x - start) / (pixels/day) == (x -s) * day / pixels 
        int dayPosition = (int) ((x - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
        int day = mFirstJulianDay + dayPosition;
 
        Time time = new Time(mTimeZone);
        if (mWeek == 0) {
            // This week is weird... 
            if (day < Time.EPOCH_JULIAN_DAY) {
                day++;
            } else if (day == Time.EPOCH_JULIAN_DAY) {
                time.set(1, 0, 1970);
                time.normalize(true);
                return time;
            } 
        } 
 
        time.setJulianDay(day);
        return time;
    } 

7
CodeRank
This code example shows how to use the following methods:normalize, set, toMillis
import android.text.format.Time; 
 
class Utils { 
    public static long createTimeInMillis(int second, int minute, int hour, int monthDay,
            int month, int year, String timezone) {
        Time t = new Time(timezone);
        t.set(second, minute, hour, monthDay, month, year);
        t.normalize(false);
        return t.toMillis(false);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setToNow, toMillis
    } 
     
    /********** Time **********/ 
     
    public static long currentTimeInMillis() { 
        Time time = new Time();
        time.setToNow();
        return time.toMillis(false);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:set
 
    @Override 
    protected void onNewIntent(Intent intent) {
        long timeMillis = Utils.timeFromIntentInMillis(intent);
        if (timeMillis > 0) {
            Time time = new Time(Utils.getTimeZone(this, null));
            time.set(timeMillis);
            goTo(time, false);
        } 
    } 
 
    @Override 
    protected void onResume() { 
        super.onResume(); 
 
        CalendarView view1 = (CalendarView) mViewSwitcher.getCurrentView();
        CalendarView view2 = (CalendarView) mViewSwitcher.getNextView();
        SharedPreferences prefs = CalendarPreferenceActivity.getSharedPreferences(this);
 
        String str = prefs.getString(CalendarPreferenceActivity.KEY_DETAILED_VIEW,
7
CodeRank
This code example shows how to use the following methods:set, toMillis
This code example shows how to use the following methods:format, set
              // タイトルとアーティスト名はそのままセットする 
              ((TextView)view).setText(cursor.getString(columnIndex));
            } else if (columnIndex == durationIndex) {
                // 再生時間はミリ秒で取得できるので 
                // mm:ssに加工 
                Time time = new Time();
                time.set(cursor.getLong(columnIndex));
                ((TextView)view).setText(time.format("%M:%S"));
            } 
            return true; 
        } 
    } 
} 
7
CodeRank

Related Android Time Questions & Answers:

See Code Examples for Android Time Methods: