我从日期生成数字,我使用的是Integer.parseInt(myDateNumberString).
我的问题是,如果数字太大,它会给我一个错误.
public Integer currentDate(){
String current_date = new SimpleDateFormat("yyyyMMddHHmm").format(Calendar.getInstance().getTime());
//int _current_date = Integer.parseInt(current_date); // Error, too big number
int _current_date = new BigInteger(current_date).intValue();
return _current_date; // Error, output: -51212897
}
Run Code Online (Sandbox Code Playgroud)
我希望获得价值,201812250203
如果我的日期格式没有mm它是好的,但我需要声明它.