阅读背景:

如何计算两个时间相差多少周年

来源:互联网 

1.通过字符串生成日历实体;

 public static Calendar getCalendarFromString(String dateStr, String dateFormatType) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormatType);
        Calendar calendar = null;
        try {
            Date date = sdf.parse(dateStr);
            calendar = Calendar.getInstance();
            calendar.setTime(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return calendar;
    } public static Calendar get



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: