本文整理汇总了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 */);
}
示例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);
}
示例3: currentTimeInMillis
import android.text.format.Time; //导入方法依赖的package包/类
/********** Time **********/
public static long currentTimeInMillis() {
Time time = new Time();
time.setToNow();
return time.toMillis(false);
}
示例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();
}
示例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;
}
示例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);
}
示例7: getTimestamp
import android.text.format.Time; //导入方法依赖的package包/类
static long getTimestamp() {
Time time = new Time();
time.setToNow();
return time.toMillis(false);
}
示例8: TimeDataPoint
import android.text.format.Time; //导入方法依赖的package包/类
public TimeDataPoint(E data, Time timestamp){
this.data = data;
this.timestamp = timestamp.toMillis(true);
}
示例9: setTimestamp
import android.text.format.Time; //导入方法依赖的package包/类
public void setTimestamp(Time timestamp){
this.timestamp = timestamp.toMillis(true);
}