小编Aji*_*wan的帖子

Java从String返回BigInteger

我从日期生成数字,我使用的是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它是好的,但我需要声明它.

java java-calendar

0
推荐指数
1
解决办法
121
查看次数

标签 统计

java ×1

java-calendar ×1