码迷,mamicode.com
首页 > 其他好文 > 详细

分离Date数据

时间:2015-09-13 23:09:15      阅读:348      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!