How to convert / cast long to String?

前端 未结 8 1109
借酒劲吻你
借酒劲吻你 2020-12-04 05:14

I just created sample BB app, which can allow to choose the date.

DateField curDateFld = new DateField(\"Choose Date: \",
  System.currentTimeMillis(), DateF         


        
8条回答
  •  误落风尘
    2020-12-04 05:44

    See the reference documentation for the String class: String s = String.valueOf(date);

    If your Long might be null and you don't want to get a 4-letter "null" string, you might use Objects.toString, like: String s = Objects.toString(date, null);


    EDIT:

    You reverse it using Long l = Long.valueOf(s); but in this direction you need to catch NumberFormatException

提交回复
热议问题