将字符串转为长整形

如何将一个字符串转变为长整型呢,其实很简单.有多个情况,

1)String bigNumber = "1234567899";
  long result = Long.valueOf(bigNumber);

2)使用java.text.NumberFormat
  String bigNumber = "1,234,567,899";
NumberFormat format = NumberFormat.getInstance(Locale.US);
        Number number = 0;
try {
number = format.parse(bigNumber);
} catch (ParseException e) {
e.printStackTrace();
}
long result = number.longValue();

你可能感兴趣的:(字符串)