android - java.lang.NumberFormatException: Invalid long: "" -


i getting dob string in format "\/date(588657600000-0400)\/" parsing below.

string target = custom.getdob(); if (target == null || target == "") {     holder.item3.settext("-"); } else {     long millis = long.parselong(target.substring(                  target.indexof("(") + 1, target.indexof("-")));     java.text.dateformat df = new simpledateformat("mm-dd-yyyy", locale.english);     holder.item3.settext(df.format(new date(millis))); } 

i getting error "04-08 22:44:09.864: e/androidruntime(3837): java.lang.numberformatexception: invalid long: "" . checking before, whether string object contains null or "" , setting "-", still getting exception.

update:

04-08 22:59:17.423: e/androidruntime(4175): java.lang.numberformatexception: invalid long: "" 04-08 22:59:17.423: e/androidruntime(4175): @ java.lang.long.invalidlong(long.java:125) 04-08 22:59:17.423: e/androidruntime(4175): @ java.lang.long.parselong(long.java:346) 04-08 22:59:17.423: e/androidruntime(4175): @ java.lang.long.parselong(long.java:319)

i changed null , empty string literal check this, still error.

if(target == null || target.equals("")) 

use string#equals compare string values; == operator compares object references equality.

if (target == null || target.equals("")) { 

you using == correctly when testing null, because ensuring target reference isn't null .


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -