美文网首页
java日期和时间提取和格式化输出

java日期和时间提取和格式化输出

作者: 手打小黑板 | 来源:发表于2020-02-12 10:09 被阅读0次
    package com.liming.date;
    
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    
    public class DateFormatTest {
        public static void main(String[] args) throws ParseException {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
            System.out.println(sdf.format(new java.util.Date()));
    
            System.out.println(Calendar.getInstance().get(Calendar.YEAR));
            System.out.println(sdf.format(sdf.parse("9999年9月9日 9时99分9秒")));
        }
    }
    
    

    相关文章

      网友评论

          本文标题:java日期和时间提取和格式化输出

          本文链接:https://www.haomeiwen.com/subject/meyqfhtx.html