关于Calendar类型转换成规定的时间格式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wxm994116/article/details/78615486
    private String calendarToString(Calendar calendar) throws Exception {
        if (calendar == null) {
            return null;
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");// 设置你想要的格式
        String dateStr = df.format(calendar.getTime());
        return dateStr;
    }

关于时间转化,发现有个博客写的比我好多了,点击查看他的吧!!
时间的相互转化,有需要直接点击以下链接

通过代码实例转换的,可以点击以下链接

猜你喜欢

转载自blog.csdn.net/wxm994116/article/details/78615486