繁体   English   中英

如果将Java Long转换为另一个基数,如何从转换后的String中取回它?

[英]If you convert a Java Long to another base, how do you get it back from the String it was converted to?

将数字转换为其他基数后:

String thirteenAsBase36 = Long.toString(13, 36);

如何将字符串转换回以10为基数的普通数字?

Long thirteenAsBase10 = ?
long parseLong(String s, int radix)
                 throws NumberFormatException

http://download.oracle.com/javase/6/docs/api/java/lang/Long.html

Long thirteenAsBase10;
try
{
    thirteenAsBase10 = Long.parseLong(thirteenAsBase36, 36);
}
catch ( NumberFormatException e )
{
    System.out.println("Oops");
}

您的第一个想法应该始终是: 阅读JavaDocs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM