首页 > 其他 > 详细

分离Date数据

时间:2015-09-13 23:08:50      阅读:317      评论:0      收藏:0      [点我收藏+]

1,java类分解:

import java.util.Calendar;
import java.util.Date;

public class Test01 {
	
	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
        Date d = new Date();
        Calendar c = Calendar.getInstance();
        c.setTime(d);
       
        int year = c.get(Calendar.YEAR);
        int month=c.get(Calendar.MONTH)+1;   
        int day =c.get(Calendar.DAY_OF_MONTH);   
        int hour =c.get(Calendar.HOUR_OF_DAY);   
        int minute =c.get(Calendar.MINUTE);   
        int second =c.get(Calendar.SECOND);
        
        System.out.println("=====年:"+year);
        System.out.println("=====月:"+month);
        System.out.println("=====日:"+day);
        System.out.println("=====时:"+hour);
        System.out.println("=====分:"+minute);
        System.out.println("=====秒:"+second);
        
        Date mydate=new Date();
        int myweekday=mydate.getDay();
        String weekday = "";
        if(myweekday == 0){
        	weekday=" 星期日";
        }
        else if(myweekday == 1){
        	weekday=" 星期一";
        }
        else if(myweekday == 2){
        	weekday=" 星期二";
        }
        else if(myweekday == 3){
        	weekday=" 星期三";
        }
        else if(myweekday == 4){
        	weekday=" 星期四";
        }
        else if(myweekday == 5){
        	weekday=" 星期五";
        }
        else if(myweekday == 6){
        	weekday=" 星期六";
        }
        System.out.println("今天是:"+weekday);
    }
	
}

 2,查询语句分解:...

 

分离Date数据

原文:http://www.cnblogs.com/bykj/p/4805783.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!