views:

1115

answers:

1

Hello friends,

I am absolutely new to Java and Blackberry development. I've started learning Java and Blackberry development. I just created sample BB app, which can allow to choose the date.

DateField curDateFld = new DateField("Choose Date: ",
  System.currentTimeMillis(), DateField.DATE | DateField.FIELD_LEFT);

After choosing the date, i need to convert that long value to String, so that i can easily store the date value somewhere in database.

long date = curDateFld.getDate();

As i haven't found any link, could someone give me the link or idea how should i convert this long value to String? Also i want to convert then again back to long from String, i think for that i can use "long l = Long.parseLong("myStr");" ?

+15  A: 

String s = String.valueOf(date);

See the reference documentation for the String class.


EDIT:

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

Gregory Pakosz
Excellent help ! Thanks a lot.