本文整理汇总了Java中android.text.format.Time.parse3339方法的典型用法代码示例。如果您正苦于以下问题:Java Time.parse3339方法的具体用法?Java Time.parse3339怎么用?Java Time.parse3339使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.format.Time
的用法示例。
在下文中一共展示了Time.parse3339方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: onHandleIntent
import android.text.format.Time; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Time time = new Time();
ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null || !ni.isConnected()) {
Log.w(TAG, "Not online, not refreshing.");
return;
}
sendStickyBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, true));
// Don't even inspect the intent, we only do one thing, and that's fetch content.
ArrayList<ContentProviderOperation> cpo = new ArrayList<ContentProviderOperation>();
Uri dirUri = ItemsContract.Items.buildDirUri();
// Delete all items
cpo.add(ContentProviderOperation.newDelete(dirUri).build());
try {
JSONArray array = RemoteEndpointUtil.fetchJsonArray();
if (array == null) {
throw new JSONException("Invalid parsed item array" );
}
for (int i = 0; i < array.length(); i++) {
ContentValues values = new ContentValues();
JSONObject object = array.getJSONObject(i);
values.put(ItemsContract.Items.SERVER_ID, object.getString("id" ));
values.put(ItemsContract.Items.AUTHOR, object.getString("author" ));
values.put(ItemsContract.Items.TITLE, object.getString("title" ));
values.put(ItemsContract.Items.BODY, object.getString("body" ));
values.put(ItemsContract.Items.THUMB_URL, object.getString("thumb" ));
values.put(ItemsContract.Items.PHOTO_URL, object.getString("photo" ));
values.put(ItemsContract.Items.ASPECT_RATIO, object.getString("aspect_ratio" ));
time.parse3339(object.getString("published_date"));
values.put(ItemsContract.Items.PUBLISHED_DATE, time.toMillis(false));
cpo.add(ContentProviderOperation.newInsert(dirUri).withValues(values).build());
}
getContentResolver().applyBatch(ItemsContract.CONTENT_AUTHORITY, cpo);
} catch (JSONException | RemoteException | OperationApplicationException e) {
Log.e(TAG, "Error updating content.", e);
}
sendStickyBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, false));
}
示例3: 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);
}
示例4: onHandleIntent
import android.text.format.Time; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Time time = new Time();
ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null || !ni.isConnected()) {
Log.w(TAG, "Not online, not refreshing.");
return;
}
sendBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, true));
// Don't even inspect the intent, we only do one thing, and that's fetch content.
ArrayList<ContentProviderOperation> cpo = new ArrayList<ContentProviderOperation>();
Uri dirUri = ItemsContract.Items.buildDirUri();
// Delete all items
cpo.add(ContentProviderOperation.newDelete(dirUri).build());
try {
JSONArray array = RemoteEndpointUtil.fetchJsonArray();
if (array == null) {
throw new JSONException("Invalid parsed item array" );
}
for (int i = 0; i < array.length(); i++) {
ContentValues values = new ContentValues();
JSONObject object = array.getJSONObject(i);
values.put(ItemsContract.Items.SERVER_ID, object.getString("id" ));
values.put(ItemsContract.Items.AUTHOR, object.getString("author" ));
values.put(ItemsContract.Items.TITLE, object.getString("title" ));
values.put(ItemsContract.Items.BODY, object.getString("body" ));
values.put(ItemsContract.Items.THUMB_URL, object.getString("thumb" ));
values.put(ItemsContract.Items.PHOTO_URL, object.getString("photo" ));
values.put(ItemsContract.Items.ASPECT_RATIO, object.getString("aspect_ratio" ));
time.parse3339(object.getString("published_date"));
values.put(ItemsContract.Items.PUBLISHED_DATE, time.toMillis(false));
cpo.add(ContentProviderOperation.newInsert(dirUri).withValues(values).build());
}
getContentResolver().applyBatch(ItemsContract.CONTENT_AUTHORITY, cpo);
} catch (JSONException | RemoteException | OperationApplicationException e) {
Log.e(TAG, "Error updating content.", e);
}
sendBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, false));
}
示例5: onHandleIntent
import android.text.format.Time; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
Time time = new Time();
ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null || !ni.isConnected()) {
Log.w(TAG, "Not online, not refreshing.");
return;
}
sendStickyBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, true));
// Don't even inspect the intent, we only do one thing, and that's fetch content.
ArrayList<ContentProviderOperation> cpo = new ArrayList<ContentProviderOperation>();
Uri dirUri = ItemsContract.Items.buildDirUri();
try {
JSONArray array = RemoteEndpointUtil.fetchJsonArray();
if (array == null) {
throw new JSONException("Invalid parsed item array");
}
for (int i = 0; i < array.length(); i++) {
ContentValues values = new ContentValues();
JSONObject object = array.getJSONObject(i);
values.put(ItemsContract.Items.SERVER_ID, object.getString("id"));
values.put(ItemsContract.Items.AUTHOR, object.getString("author"));
values.put(ItemsContract.Items.TITLE, object.getString("title"));
values.put(ItemsContract.Items.BODY, object.getString("body"));
values.put(ItemsContract.Items.THUMB_URL, object.getString("thumb"));
values.put(ItemsContract.Items.PHOTO_URL, object.getString("photo"));
values.put(ItemsContract.Items.ASPECT_RATIO, object.getString("aspect_ratio"));
time.parse3339(object.getString("published_date"));
values.put(ItemsContract.Items.PUBLISHED_DATE, time.toMillis(false));
Long id = Long.valueOf(object.getString("id"));
Cursor cursor = getContentResolver().query(ItemsContract.Items.buildDirUri(),
ArticleLoader.Query.PROJECTION, ItemsContract.Items.SERVER_ID + "=" + id,
null, null);
if (cursor == null || !cursor.moveToFirst()) {
cpo.add(ContentProviderOperation.newInsert(dirUri).withValues(values).build());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
getContentResolver().applyBatch(ItemsContract.CONTENT_AUTHORITY, cpo);
} catch (JSONException | RemoteException | OperationApplicationException e) {
Log.e(TAG, "Error updating content.", e);
}
sendStickyBroadcast(
new Intent(BROADCAST_ACTION_STATE_CHANGE).putExtra(EXTRA_REFRESHING, false));
}