當前位置: 首頁>>代碼示例>>Java>>正文


Java Time.toMillis方法代碼示例

本文整理匯總了Java中android.text.format.Time.toMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java Time.toMillis方法的具體用法?Java Time.toMillis怎麽用?Java Time.toMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.format.Time的用法示例。


在下文中一共展示了Time.toMillis方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import android.text.format.Time; //導入方法依賴的package包/類
public static long parse(String timeString)
        throws IllegalArgumentException {

    int date = 1;
    int month = Calendar.JANUARY;
    int year = 1970;
    TimeOfDay timeOfDay;

    Matcher rfcMatcher = HTTP_DATE_RFC_PATTERN.matcher(timeString);
    if (rfcMatcher.find()) {
        date = getDate(rfcMatcher.group(1));
        month = getMonth(rfcMatcher.group(2));
        year = getYear(rfcMatcher.group(3));
        timeOfDay = getTime(rfcMatcher.group(4));
    } else {
        Matcher ansicMatcher = HTTP_DATE_ANSIC_PATTERN.matcher(timeString);
        if (ansicMatcher.find()) {
            month = getMonth(ansicMatcher.group(1));
            date = getDate(ansicMatcher.group(2));
            timeOfDay = getTime(ansicMatcher.group(3));
            year = getYear(ansicMatcher.group(4));
        } else {
            throw new IllegalArgumentException();
        }
    }

    // FIXME: Y2038 BUG!
    if (year >= 2038) {
        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 */);
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:39,代碼來源:HttpDateTime.java

示例2: a

import android.text.format.Time; //導入方法依賴的package包/類
public static long a(String str) {
    int c;
    int d;
    a e;
    int i;
    int i2 = 1;
    Matcher matcher = a.matcher(str);
    int b;
    if (matcher.find()) {
        b = b(matcher.group(1));
        c = c(matcher.group(2));
        d = d(matcher.group(3));
        e = e(matcher.group(4));
        i = b;
    } else {
        Matcher matcher2 = b.matcher(str);
        if (matcher2.find()) {
            c = c(matcher2.group(1));
            b = b(matcher2.group(2));
            a e2 = e(matcher2.group(3));
            d = d(matcher2.group(4));
            e = e2;
            i = b;
        } else {
            throw new IllegalArgumentException();
        }
    }
    if (d >= 2038) {
        d = 2038;
        c = 0;
    } else {
        i2 = i;
    }
    Time time = new Time("UTC");
    time.set(e.c, e.b, e.a, i2, c, d);
    return time.toMillis(false);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:38,代碼來源:k.java

示例3: currentTimeInMillis

import android.text.format.Time; //導入方法依賴的package包/類
/********** Time **********/

public static long currentTimeInMillis() {
    Time time = new Time();
    time.setToNow();
    return time.toMillis(false);
}
 
開發者ID:lskk,項目名稱:Steppy-Android,代碼行數:8,代碼來源:Utils.java

示例4: run

import android.text.format.Time; //導入方法依賴的package包/類
@SuppressLint("SimpleDateFormat")
@Override
public void run() {
    // 實時發送一個更新的廣播
    final String pref_key = "appwidget_news_refresh_time";
    final long updatePeriod = 10 * 60 * 1000;
    final long lastRefreshTime = Utils.getLong(this, pref_key, 0);
    final long now = System.currentTimeMillis();
    if (now - lastRefreshTime >= updatePeriod) {
        // 10分鍾內不執行重複的後台更新請求
        Utils.putLong(this, pref_key, now);

        Intent refreshNowIntent = new Intent(this, NewsAppWidgetProvider.class);
        refreshNowIntent.setAction(NewsAppWidgetProvider.ACTION_REFRESH_AUTO);
        sendBroadcast(refreshNowIntent);
    }

    Intent autoRefreshIntent = new Intent(this, NewsAppWidgetProvider.class);
    autoRefreshIntent.setAction(NewsAppWidgetProvider.ACTION_REFRESH_AUTO);
    PendingIntent pending = PendingIntent.getBroadcast(NewsWidgetService.this, 0, autoRefreshIntent, 0);

    // 1*60秒更新一次
    final long updateTime = 1 * 60 * 1000;
    Time time = new Time();
    long nowMillis = System.currentTimeMillis();
    time.set(nowMillis + updateTime);
    long updateTimes = time.toMillis(true);

    // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    // Log.d(TAG, "request next update at " + updateTimes);
    // Log.d(TAG, "refresh time: " + sdf.format(new Date()));

    AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, updateTimes, pending);
    stopSelf();
}
 
開發者ID:benniaobuguai,項目名稱:opencdk-appwidget,代碼行數:37,代碼來源:NewsWidgetService.java

示例5: getExpire

import android.text.format.Time; //導入方法依賴的package包/類
public Date getExpire() {
    if (null != expire) {
        Time time = new Time();
        if (time.parse3339(expire)) {
            return new Date(time.toMillis(true));
        }
    }
    return null;
}
 
開發者ID:uriio,項目名稱:uriio-android,代碼行數:10,代碼來源:ShortUrl.java

示例6: parseTime

import android.text.format.Time; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:10,代碼來源:ParserUtils.java

示例7: getTimestamp

import android.text.format.Time; //導入方法依賴的package包/類
static long getTimestamp() {
    Time time = new Time();
    time.setToNow();
    return time.toMillis(false);
}
 
開發者ID:ZyreApps,項目名稱:chat-android,代碼行數:6,代碼來源:Helpers.java

示例8: TimeDataPoint

import android.text.format.Time; //導入方法依賴的package包/類
public TimeDataPoint(E data, Time timestamp){
	this.data = data;
	this.timestamp = timestamp.toMillis(true);
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:5,代碼來源:TimeDataPoint.java

示例9: setTimestamp

import android.text.format.Time; //導入方法依賴的package包/類
public void setTimestamp(Time timestamp){
	this.timestamp = timestamp.toMillis(true);
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:4,代碼來源:TimeDataPoint.java


注:本文中的android.text.format.Time.toMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。