APISonar


android.text.format.Time.Time

> android > text > format > Time > Time
android APIs text APIs format APIs Time APIs Time APIs

Example 1
private static String formatTime(long millis) {
        final Time time = new Time(Time.TIMEZONE_UTC);
        time.set(millis);
        return time.format3339(false);
    }
Example 2
public Time getSelectedDay() {
        Time time = new Time(mBaseDate);
        time.setJulianDay(mSelectionDay);
        time.hour = mSelectionHour;

        // We ignore the "isDst" field because we want normalize() to figure
        // out the correct DST value and not adjust the selected time based
        // on the current setting of DST.
        time.normalize(true /* ignore isDst */);
        return time;
    }
Example 3
public void setTime(long time) {
        Time t = new Time();
        t.set(time);
        mTimeMillis = t.toMillis(false);
        mTime = new Date(t.year-1900, t.month, t.monthDay, t.hour, t.minute, 0);
        update();
    }
Example 4
public void testIsEpoch() throws Exception {
    Time t = new Time();
    boolean isEpoch = Time.isEpoch(t);
    assertEquals(true, isEpoch);
  }
Example 5
public void testMillis1() throws Exception {
        Time t = new Time(Time.TIMEZONE_UTC);
        t.set(1, 0, 0, 1, 0, 1970);
        long r = t.toMillis(true /* ignore isDst */);
        // System.out.println("r=" + r);
    }
Example 6
public void refresh(Context context) {
        mTimeZone = Utils.getTimeZone(context, mTimeUpdater);
        Time time = new Time(mTimeZone);
        long now = System.currentTimeMillis();
        time.set(now);
        mTodayJulianDay = Time.getJulianDay(now, time.gmtoff);
        updateTitle();
        setMidnightHandler();
    }
Example 7
private static Time addMonth(Time t, int months) {
        final Time rt = new Time(t);
        rt.set(t.monthDay, t.month + months, t.year);
        rt.normalize(false);
        return rt;
    }
Example 8
public void testNormalize0() throws Exception {
        Time t = new Time(Time.TIMEZONE_UTC);
        t.parse("20060432T010203");
        t.normalize(false /* use isDst */);
//        System.out.println("got: " + t.year + '-'
//                + t.month + '-' + t.monthDay
//                + ' ' + t.hour + ':' + t.minute
//                + ':' + t.second
//                + "( " + t.isDst + ',' + t.gmtoff
//                + ',' + t.weekDay
//                + ',' + t.yearDay + ')');
    }
Example 9
public void shouldHaveToMillis() throws Exception {
    Time t = new Time();
    t.set(86400 * 1000);
    assertEquals(86400 * 1000, t.toMillis(false));
  }
Example 10
public DateFormatter(Context context)
    {
        mContext = context;
        mNow = new Time();
    }
Example 11
String getFormattedTime(long timeInMillis, Activity ctx) {
		StringBuilder timeStringBuilder = new StringBuilder();
		Time time = new Time();
		time.set(timeInMillis);
		timeStringBuilder.append(time.hour);
		timeStringBuilder.append(":");
		int minute = time.minute;
		timeStringBuilder.append(minute < 10 ? "0" + minute : minute);
		if (!DateFormat.is24HourFormat(ctx)) {
			timeStringBuilder.append(time.hour >= 12 ? ctx.getString(R.string.osmand_parking_pm) : ctx
					.getString(R.string.osmand_parking_am));
		}
		return timeStringBuilder.toString();
	}
Example 12
private String formatDateString(int julianDay) {
        Time time = new Time(mTimeZone);
        time.setJulianDay(julianDay);
        long millis = time.toMillis(false);
        mStringBuilder.setLength(0);
        return DateUtils.formatDateRange(mContext, mFormatter, millis, millis,
                DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE
                        | DateUtils.FORMAT_ABBREV_MONTH, mTimeZone).toString();
    }
Example 13
public void shouldFormat() throws Exception {
    Time t = new Time(Time.TIMEZONE_UTC);
    t.set(3600000L);

    assertEquals("Hello epoch 01 1970 01", t.format("Hello epoch %d %Y %d"));
    assertEquals("Hello epoch  1:00 AM", t.format("Hello epoch %l:%M %p"));
  }
Example 14
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;
    }
Example 15
private final String toRfc2455Format(final long millSecs) {
        Time startDate = new Time();
        startDate.set(millSecs);
        String date = startDate.format2445();
        return date + FLAG_TIMEZONE_UTC;
    }
Example 16
private void setDayParameters(Time day) {
        day.timezone = mHomeTimeZone;
        Time currTime = new Time(mHomeTimeZone);
        currTime.set(mController.getTime());
        day.hour = currTime.hour;
        day.minute = currTime.minute;
        day.allDay = false;
        day.normalize(true);
    }
Example 17
static String formatDebugTime(long unixTime, long now) {
        Time time = new Time();
        time.set(unixTime);

        long delta = unixTime - now;
        if (delta > DateUtils.MINUTE_IN_MILLIS) {
            delta /= DateUtils.MINUTE_IN_MILLIS;
            return String.format("[%d] %s (%+d mins)", unixTime,
                    time.format("%H:%M:%S"), delta);
        } else {
            delta /= DateUtils.SECOND_IN_MILLIS;
            return String.format("[%d] %s (%+d secs)", unixTime,
                    time.format("%H:%M:%S"), delta);
        }
    }
Example 18
public void shouldSetToNow() throws Exception {
    Time t = new Time();
    SystemClock.setCurrentTimeMillis(1000);
    t.setToNow();
    assertThat(t.toMillis(false)).isEqualTo(1000);
  }
Example 19
public void shouldHaveSetTime() throws Exception {
    Time t = new Time();
    t.setToNow();
    Time t2 = new Time();
    t2.set(t);
    assertEquals(t.timezone, t2.timezone);
    assertEquals(t.year, t2.year);
    assertEquals(t.month, t2.month);
    assertEquals(t.monthDay, t2.monthDay);
    assertEquals(t.hour, t2.hour);
    assertEquals(t.minute, t2.minute);
    assertEquals(t.second, t2.second);
  }
Example 20
public void shouldFormatAllFormats_withQuestionableResults() throws Exception {
    Time t = new Time("Asia/Tokyo");
    t.set(1407496560000L);

    assertEquals("08/08/2014", t.format("%x"));
    assertEquals("08:16:00 PM", t.format("%X"));

    // Case.
    assertEquals("PM", t.format("%^P"));
    assertEquals("PM", t.format("%#P"));
  }
Example 21
public CalendarAppWidgetModel(Context context, String timeZone) {
        mNow = System.currentTimeMillis();
        Time time = new Time(timeZone);
        time.setToNow(); // This is needed for gmtoff to be set
        mTodayJulianDay = Time.getJulianDay(mNow, time.gmtoff);
        mMaxJulianDay = mTodayJulianDay + CalendarAppWidgetService.MAX_DAYS - 1;
        mEventInfos = new ArrayList<EventInfo>(50);
        mRowInfos = new ArrayList<RowInfo>(50);
        mDayInfos = new ArrayList<DayInfo>(8);
        mContext = context;
    }
Example 22
public void testSet0() throws Exception {
        Time t = new Time(Time.TIMEZONE_UTC);
        t.set(1000L);
        // System.out.println("t.year=" + t.year);
        // System.out.println("t=" + t);
        t.set(2000L);
        // System.out.println("t=" + t);
        t.set(1000L * 60);
        // System.out.println("t=" + t);
        t.set((1000L * 60 * 60 * 24) + 1000L);
        // System.out.println("t=" + t);
    }
Example 23
protected long constructDefaultStartTime(long now) {
        Time defaultStart = new Time();
        defaultStart.set(now);
        defaultStart.second = 0;
        defaultStart.minute = 30;
        long defaultStartMillis = defaultStart.toMillis(false);
        if (now < defaultStartMillis) {
            return defaultStartMillis;
        } else {
            return defaultStartMillis + 30 * DateUtils.MINUTE_IN_MILLIS;
        }
    }
Example 24
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;
    }
Example 25
private DayAdapterInfo getAdapterInfoByTime(Time time) {
        if (DEBUGLOG) Log.e(TAG, "getAdapterInfoByTime " + time.toString());

        Time tmpTime = new Time(time);
        long timeInMillis = tmpTime.normalize(true);
        int day = Time.getJulianDay(timeInMillis, tmpTime.gmtoff);
        synchronized (mAdapterInfos) {
            for (DayAdapterInfo info : mAdapterInfos) {
                if (info.start <= day && day <= info.end) {
                    return info;
                }
            }
        }
        return null;
    }