首页前端开发HTMLDate,DateFormat,Calendar类的使用

Date,DateFormat,Calendar类的使用

时间2024-01-25 12:03:44发布访客分类HTML浏览137
导读:收集整理的这篇文章主要介绍了html5教程-Date,DateFormat,Calendar类的使用,觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。...
收集整理的这篇文章主要介绍了html5教程-Date,DateFormat,Calendar类的使用,觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
[htML] 
package com.ITheima.date;  
 
import java.util.Calendar;  
 
public class CalendarDemo1 {  
    public static void main(String[] args) {  
        Calendar c = Calendar.getInstance();  
        c.set(2012, 11, 16); //设置时间从0开始 ,0 ---一月 
        c.add(Calendar.MONTH, 4);   //增量。 
         
        PRintCalendar(c);  
         
    }     
    private static void sop(Object obj) {  
        System.out.println(obj);  
    }  
    private static  void printCalendar(Calendar c) {  
        /* 
         * 使用查表法获取中文月,星期 
         */ 
        String[] mons = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", 
                "十月", "十一月", "十二月" } ;  
        String[] weeks = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" } ;  
        int index = c.get(Calendar.MONTH);  
        int index1 = c.get(Calendar.DAY_OF_WEEK);  
 
        sop(c.get(Calendar.YEAR) + "年");  
//      sop((c.get(Calendar.MONTH) + 1) + "月");  
        sop(mons[index]);  
        sop(c.get(Calendar.DAY_OF_MONTH)+"日");  
//      sop("星期"+c.get(Calendar.DAY_OF_WEEK));  
        sop(weeks[index1]);  
 
    }  
 
    }  

[html] 
package com.itheima.date;  
 
import java.util.Calendar;  
 
public class CalendarDemo1 {  
    public static void main(String[] args) {  
        Calendar c = Calendar.getInstance();  
        c.set(2012, 11, 16); //设置时间从0开始 ,0 ---一月 
        c.add(Calendar.MONTH, 4);   //增量。 
         
        printCalendar(c);  
         
    }     
    private static void sop(Object obj) {  
        System.out.println(obj);  
    }  
    private static  void printCalendar(Calendar c) {  
        /* 
         * 使用查表法获取中文月,星期 
         */ 
        String[] mons = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", 
                "十月", "十一月", "十二月" } ;  
        String[] weeks = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" } ;  
        int index = c.get(Calendar.MONTH);  
        int index1 = c.get(Calendar.DAY_OF_WEEK);  
 
        sop(c.get(Calendar.YEAR) + "年");  
//      sop((c.get(Calendar.MONTH) + 1) + "月");  
        sop(mons[index]);  
        sop(c.get(Calendar.DAY_OF_MONTH)+"日");  
//      sop("星期"+c.get(Calendar.DAY_OF_WEEK));  
        sop(weeks[index1]);  
 
    }  
 
    }  

觉得可用,就经常来吧! 欢迎评论哦! html5教程,巧夺天工,精雕玉琢。小宝典献丑了!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

ClassdivHTMLImportpost-format-gallery

若转载请注明出处: Date,DateFormat,Calendar类的使用
本文地址: https://pptw.com/jishu/586493.html
html5跨平台---phoneGap介绍 利用Jekyll-Bootstrap搭建github blog 简单记录

游客 回复需填写必要信息