其他分享
首页 > 其他分享> > 获取日期可设置月份和年份

获取日期可设置月份和年份

作者:互联网

public static final String getDate1() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, 12);
        calendar.set(Calendar.DAY_OF_MONTH, 2);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND,0);
        Date beforeDate = calendar.getTime();
        String time = sdf.format(beforeDate);
        return time;
    }

标签:年份,String,DAY,获取,日期,set,calendar,MONTH,Calendar
来源: https://blog.csdn.net/weixin_47467938/article/details/122041519