本文整理汇总了Java中java.lang.Long.parseLong方法的典型用法代码示例。如果您正苦于以下问题:Java Long.parseLong方法的具体用法?Java Long.parseLong怎么用?Java Long.parseLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Long
的用法示例。
在下文中一共展示了Long.parseLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDue
import java.lang.Long; //导入方法依赖的package包/类
/**
* 判断缓存的byte数据是否到期
*
* @param data
* @return true:到期了 false:还没有到期
*/
private static boolean isDue(byte[] data) {
String[] strs = getDateInfoFromDate(data);
if (strs != null && strs.length == 2) {
String saveTimeStr = strs[0];
while (saveTimeStr.startsWith("0")) {
saveTimeStr = saveTimeStr.substring(1, saveTimeStr.length());
}
long saveTime = Long.parseLong(saveTimeStr);
long deleteAfter = Long.parseLong(strs[1]);
if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) {
return true;
}
}
return false;
}
示例2: persist
import java.lang.Long; //导入方法依赖的package包/类
public void persist(Long started, Long received, Long transmitted) {
Log.d(TAG, "persist");
SQLiteDatabase db = this.getWritableDatabase();
Long previousReceived = 0L;
Long previousTransmitted = 0L;
Cursor cursor = db.rawQuery(QUERY_FIND, new String[] {started.toString()});
if (cursor.moveToFirst()) {
previousReceived = Long.parseLong(cursor.getString(1), 10);
previousTransmitted = Long.parseLong(cursor.getString(2), 10);
}
cursor.close();
ContentValues values = new ContentValues();
values.put(COLUMN_STARTED, started);
values.put(COLUMN_RECEIVED, received + previousReceived);
values.put(COLUMN_TRANSMITTED, transmitted + previousTransmitted);
db.replace(TABLE_NAME, null, values);
db.close();
}
示例3: retrieve
import java.lang.Long; //导入方法依赖的package包/类
public List<HarvestTrafficEntry> retrieve(Long started) {
Log.d(TAG, "retrieve");
List<HarvestTrafficEntry> entries = new ArrayList<HarvestTrafficEntry>();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(QUERY_SELECT, new String[] {started.toString()});
if (cursor.moveToFirst()) {
do {
HarvestTrafficEntry entry = new HarvestTrafficEntry();
entry.started = Long.parseLong(cursor.getString(0), 10);
entry.received = Long.parseLong(cursor.getString(1), 10);
entry.transmitted = Long.parseLong(cursor.getString(2), 10);
Log.d(TAG, String.format("retrieve: %d %d %d", entry.started, entry.received, entry.transmitted));
entries.add(entry);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return entries;
}
示例4: persist
import java.lang.Long; //导入方法依赖的package包/类
public void persist(HarvestEntry entry) {
Log.d("HarvestStore", "persist");
SQLiteDatabase db = this.getWritableDatabase();
Long previousDuration = 0L;
Cursor cursor = db.rawQuery(QUERY_FIND, new String[] {entry.packageName, entry.started.toString()});
if (cursor.moveToFirst()) {
previousDuration = Long.parseLong(cursor.getString(2), 10);
}
cursor.close();
ContentValues values = new ContentValues();
values.put(COLUMN_PACKAGE, entry.packageName);
values.put(COLUMN_STARTED, entry.started);
values.put(COLUMN_DURATION, entry.duration + previousDuration);
db.replace(TABLE_NAME, null, values);
db.close();
}
示例5: retrieve
import java.lang.Long; //导入方法依赖的package包/类
public List<HarvestEntry> retrieve(Long started) {
Log.d("HarvestStore", "retrieve");
List<HarvestEntry> entries = new ArrayList<HarvestEntry>();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(QUERY_SELECT, new String[] {started.toString()});
if (cursor.moveToFirst()) {
do {
HarvestEntry entry = new HarvestEntry(cursor.getString(0));
entry.started = Long.parseLong(cursor.getString(1), 10);
entry.duration = Long.parseLong(cursor.getString(2), 10);
entries.add(entry);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return entries;
}
示例6: updateTo
import java.lang.Long; //导入方法依赖的package包/类
private void updateTo() {
String from = this.fromView.getText().toString();
long newNumber;
try {
newNumber = Long.parseLong(from,this.fromBase);
}catch(NumberFormatException e){
Toast.makeText(getApplicationContext(), "This number is too big",
1).show();
newNumber = ~((int)0); //horrible kludge to max out number.
}
this.toView.setText(Long.toString(newNumber, this.toBase));
}
示例7: onItemClick
import java.lang.Long; //导入方法依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int pos, long id)
{
if ( mMenu == (ListView)parent ) {
handleMenu( pos );
return;
}
if ( onMenu ) {
closeMenu();
return;
}
CharSequence item = ((TextView) view).getText();
String value = item.toString();
// TDLog.Log( TDLog.LOG_INPUT, "GMActivity onItemClick() " + item.toString() );
// if ( value.equals( getResources().getString( R.string.back_to_calib ) ) ) {
// setStatus( TDStatus.CALIB );
// updateDisplay( );
// return;
// }
mSaveCBlock = mDataAdapter.get( pos );
mSaveTextView = (TextView) view;
String msg = mSaveTextView.getText().toString();
String[] st = msg.split( " ", 3 );
try {
mCIDid = Long.parseLong(st[0]);
// String name = st[1];
mSaveData = st[2];
if ( mSaveCBlock.mStatus == 0 ) {
// startGMDialog( mCIDid, st[1] );
(new CalibGMDialog( this, this, mSaveCBlock )).show();
} else { // FIXME TODO ask whether to undelete
TopoDroidAlertDialog.makeAlert( this, getResources(), R.string.calib_gm_undelete,
new DialogInterface.OnClickListener() {
@Override
public void onClick( DialogInterface dialog, int btn ) {
// TDLog.Log( TDLog.LOG_INPUT, "calib delite" );
deleteGM( false );
}
}
);
}
} catch ( NumberFormatException e ) {
TDLog.Error( "error: expected a long, got: " + st[0] );
}
}
示例8: getLong
import java.lang.Long; //导入方法依赖的package包/类
/**
* Implements the <tt>getLong</tt> method as per the specification in
* {@link Preferences#getLong(String,long)}.
*
* <p>This implementation invokes {@link #get(String,String) <tt>get(key,
* null)</tt>}. If the return value is non-null, the implementation
* attempts to translate it to a <tt>long</tt> with
* {@link Long#parseLong(String)}. If the attempt succeeds, the return
* value is returned by this method. Otherwise, <tt>def</tt> is returned.
*
* @param key key whose associated value is to be returned as a long.
* @param def the value to be returned in the event that this
* preference node has no value associated with <tt>key</tt>
* or the associated value cannot be interpreted as a long.
* @return the long value represented by the string associated with
* <tt>key</tt> in this preference node, or <tt>def</tt> if the
* associated value does not exist or cannot be interpreted as
* a long.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
*/
public long getLong(String key, long def) {
long result = def;
try {
String value = get(key, null);
if (value != null)
result = Long.parseLong(value);
} catch (NumberFormatException e) {
// Ignoring exception causes specified default to be returned
}
return result;
}
示例9: getLong
import java.lang.Long; //导入方法依赖的package包/类
/**
* Implements the {@code getLong} method as per the specification in
* {@link Preferences#getLong(String,long)}.
*
* <p>This implementation invokes {@link #get(String,String) get(key,
* null)}. If the return value is non-null, the implementation
* attempts to translate it to a {@code long} with
* {@link Long#parseLong(String)}. If the attempt succeeds, the return
* value is returned by this method. Otherwise, {@code def} is returned.
*
* @param key key whose associated value is to be returned as a long.
* @param def the value to be returned in the event that this
* preference node has no value associated with {@code key}
* or the associated value cannot be interpreted as a long.
* @return the long value represented by the string associated with
* {@code key} in this preference node, or {@code def} if the
* associated value does not exist or cannot be interpreted as
* a long.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if {@code key} is {@code null}.
* @throws IllegalArgumentException if key contains the null control
* character, code point U+0000.
*/
public long getLong(String key, long def) {
long result = def;
try {
String value = get(key, null);
if (value != null)
result = Long.parseLong(value);
} catch (NumberFormatException e) {
// Ignoring exception causes specified default to be returned
}
return result;
}