Convert Current date to integer

前端 未结 12 888
轮回少年
轮回少年 2020-12-05 04:35

I want to convert the current date to integer value. By default, it returns long. When I try to convert long to integer, and afterwards I convert the integer value to date,

12条回答
  •  渐次进展
    2020-12-05 04:55

    I've solved this as is shown below:

        long year = calendar.get(Calendar.YEAR);
        long month = calendar.get(Calendar.MONTH) + 1;
        long day = calendar.get(Calendar.DAY_OF_MONTH);
        long calcDate = year * 100 + month;
        calcDate = calcDate * 100 + day;
        System.out.println("int: " + calcDate);
    

提交回复
热议问题