先上張效果圖:以下是實現(xiàn)代碼:/*日歷*/
成都創(chuàng)新互聯(lián)是專業(yè)的長春網(wǎng)站建設(shè)公司,長春接單;提供成都網(wǎng)站建設(shè)、做網(wǎng)站,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行長春網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.regex.Pattern;
import javax.swing.*;
public class Demo28 extends JFrame {
int m = 1;
String[] monthchoose = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12" }; // 存放月份的字符數(shù)組
String[] columnNames = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; // 存放星期的字符數(shù)組
Calendar ca = Calendar.getInstance();
Container contentPane = getContentPane();
VectorString vector = new VectorString();
String[][] date = new String[6][7]; // 表格的顯示數(shù)據(jù)的格式
TextField tf; // 文本框的值代表的是年份
JComboBox jb;
JTable table; // 把日期用table的方式顯示出來
public void getDate(String year, String month, String week, int Max_Day) {
int n = 0, b = 0;
// 動態(tài)把傳進來月份的天數(shù)存放到容器里
for (int j = 1; j = Max_Day; j++) {
vector.add(String.valueOf(j));
}
//每次往table里添加數(shù)據(jù)的時候,都預先把原table里 的 數(shù)據(jù)清空
for(int x = 0;xdate.length;x++){
for(int y = 0;ydate[x].length;y++){
date[x][y] = null;
}
}
// 根據(jù)傳進來月份的第一天是星期幾,來構(gòu)建Table
for (int a = Integer.parseInt(week) - 1; a date[0].length; a++) {
date[0][a] = new String((String) vector.toArray()[n]);
n++;
}
for (int i = 1; i date.length; i++) {
for (int j = 0; j date[i].length; j++) {
if (n vector.size()) {
date[i][j] = new String((String) vector.toArray()[n]);
n++;
} else
break;
}
}
// 把容器里的數(shù)據(jù)全部清除,以備下次再存放新的數(shù)據(jù)
while (b vector.size()) {
vector.remove(b);
}
}
public void chooseDate(String day) {
JLabel label = new JLabel();
for (int y = 0; y date.length; y++) {
for (int z = 0; z date[y].length; z++) {
System.out.print(date[y][z] + " ");
System.out.println(day);
if (date[y][z] != null) {
if (date[y][z].equals(day)) {
table.setSelectionBackground(Color.yellow);
return;
}
}
}
}
}
public void paint() {
setTitle("日歷");
setBounds(200, 200, 350, 178);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
int m = 0;
String year = String.valueOf(ca.get(Calendar.YEAR)); // 得到當前的系統(tǒng)時間的年份,并把這個數(shù)值存放到y(tǒng)ear這個變量里
String month = String.valueOf(ca.get(Calendar.MONTH) + 1); // 得到當前的系統(tǒng)時間的月份,并把這個數(shù)值存放到month這個變量里
String day = String.valueOf(ca.get(Calendar.DATE)); // 得到當前的系統(tǒng)時間的日期,并把這個數(shù)值存放到day這個變量里
ca.set(Calendar.DATE, 1); // 把Calendar 對象的DATA設(shè)置為1
String week = String.valueOf(ca.get(Calendar.DAY_OF_WEEK)); // 根據(jù)設(shè)置的Calendar對象,計算出這個月第一天是星期幾
int Max_Day = ca.getActualMaximum(Calendar.DATE); // 得到當前系統(tǒng)時間月份有多少天
getDate(year, month, week, Max_Day);
// 從月份數(shù)組里取出與當前系統(tǒng)時間一樣的月份值
for (int i = 0; i monthchoose.length; i++) {
if (monthchoose[i].equals(month)) {
m = i;
}
}
JToolBar toolBar = new JToolBar();
JButton b1 = new JButton("<");
b1.addMouseListener(new myMouseListener1());
JButton b2 = new JButton(">");
b2.addMouseListener(new myMouseListener2());
JLabel j1 = new JLabel("年");
JLabel j2 = new JLabel("月");
tf = new TextField(5);
tf.addKeyListener(new myKeyListener());
tf.setText(year);
jb = new JComboBox(monthchoose);
jb.setSelectedIndex(m);
jb.addActionListener(new myActionListener3());
table = new JTable(date, columnNames);
//table.addMouseListener(new tableMouseListener());
table.setPreferredScrollableViewportSize(new Dimension(350, 150));
JScrollPane jsp = new JScrollPane(table);
contentPane.add(jsp, BorderLayout.CENTER);
chooseDate(day);
toolBar.add(b1);
toolBar.add(tf);
toolBar.add(b2);
toolBar.add(j1);
toolBar.add(jb);
toolBar.add(j2);
toolBar.setLocation(0, 0);
toolBar.setSize(400, 15);
contentPane.add(toolBar, BorderLayout.NORTH);
setVisible(true);
new Thread(new PaintThread()).start(); // 調(diào)用內(nèi)部類PaintThread,根據(jù)里面的設(shè)置來重畫
}
public static void main(String[] args) {
Demo28 d28 = new Demo28();
d28.paint();
}
// 鼠標單擊左邊按鈕觸發(fā)的事件
class myMouseListener1 extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
String str = tf.getText().trim(); // 得到文本框的值
int i = Integer.parseInt(str);
i = i - 1;
tf.setText(String.valueOf(i));
String new_year = String.valueOf(i); // 把表示年份的文本框的值存放到變量new_year里
ca.set(Calendar.YEAR, i); // 把Calendar 對象的YEAR設(shè)置為用戶設(shè)置的年份
String new_month = (String) jb.getSelectedItem(); // 得到月份值
ca.set(Calendar.MONTH, Integer.parseInt(new_month) - 1); // 把Calendar對象的MONTH設(shè)置為用戶設(shè)置的月份
ca.set(Calendar.DATE, 1); // 把Calendar 對象的DATA設(shè)置為1
String new_week = String.valueOf(ca.get(Calendar.DAY_OF_WEEK)); // 根據(jù)設(shè)置的Calendar對象,計算出這個月第一天是星期幾
int Max_Day = ca.getActualMaximum(Calendar.DATE); // 根據(jù)設(shè)置后的Calendar對象計算這個月份有多少天
getDate(new_year, new_month, new_week, Max_Day);
}
}
class myKeyListener extends KeyAdapter {
public void keyReleased(KeyEvent e) {
try {
int i = Integer.parseInt(tf.getText().trim());
int key = e.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
String new_year = String.valueOf(i);
ca.set(Calendar.YEAR, i); // 把Calendar對象的YEAR設(shè)置為用戶設(shè)置的年份
String new_month = (String) jb.getSelectedItem(); // 得到月份值
ca.set(Calendar.MONTH, Integer.parseInt(new_month) - 1); // 把Calendar對象的MONTH設(shè)置為用戶設(shè)置的月份
ca.set(Calendar.DATE, 1); // 把Calendar 對象的DATA設(shè)置為1
String new_week = String.valueOf(ca
.get(Calendar.DAY_OF_WEEK)); // 根據(jù)設(shè)置的Calendar對象,計算出這個月第一天是星期幾
int Max_Day = ca.getActualMaximum(Calendar.DATE); // 根據(jù)設(shè)置后的Calendar對象計算這個月份有多少天
getDate(new_year, new_month, new_week, Max_Day);
}
} catch (NumberFormatException excption) {
System.out.println("你輸入的年份不正確!");
}
}
}
// 鼠標單擊右邊按鈕觸發(fā)的事件
class myMouseListener2 extends MouseAdapter {
public void mouseClicked(MouseEvent e) {
String str = tf.getText().trim();
int i = Integer.parseInt(str);
i = i + 1;
tf.setText(String.valueOf(i));
String new_year = String.valueOf(i); // 把表示年份的文本框的值存放到變量new_year里
ca.set(Calendar.YEAR, i); // 把Calendar 對象的YEAR設(shè)置為用戶設(shè)置的年份
String new_month = (String) jb.getSelectedItem(); // 得到月份值
ca.set(Calendar.MONTH, Integer.parseInt(new_month) - 1); // 把Calendar對象的MONTH設(shè)置為用戶設(shè)置的月份
ca.set(Calendar.DATE, 1); // 把Calendar 對象的DATA設(shè)置為1
String new_week = String.valueOf(ca.get(Calendar.DAY_OF_WEEK)); // 根據(jù)設(shè)置的Calendar對象,計算出這個月第一天是星期幾
int Max_Day = ca.getActualMaximum(Calendar.DATE); // 根據(jù)設(shè)置后的Calendar對象計算這個月份有多少天
getDate(new_year, new_month, new_week, Max_Day);
}
}
// 鼠標單擊選擇框觸發(fā)的事件
class myActionListener3 implements ActionListener {
public void actionPerformed(ActionEvent e) {
String new_year = String.valueOf(ca.get(Calendar.YEAR)); // 把表示年份的文本框的值存放到變量new_year里
String new_month = (String) jb.getSelectedItem(); // 得到用戶設(shè)置的月份
ca.set(Calendar.MONTH, Integer.parseInt(new_month) - 1); // 把Calendar對象的月份值設(shè)置為用戶定義的月份
ca.set(Calendar.DATE, 1); // 把Calendar 對象的DATA設(shè)置為1
String new_week = String.valueOf(ca.get(Calendar.DAY_OF_WEEK)); // 根據(jù)設(shè)置的Calendar對象,計算出這個月第一天是星期幾
int Max_Day = ca.getActualMaximum(Calendar.DATE); // 根據(jù)設(shè)置后的Calendar對象計算這個月份有多少天
getDate(new_year, new_month, new_week, Max_Day);
}
}
// 重畫組件
private class PaintThread implements Runnable {
public void run() {
while (true) {
repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
我有個JS的要么?
你可以把他改下我是沒時間幫你該哈!!!
!--日期框選擇--
var DS_x,DS_y;
function dateSelector() //構(gòu)造dateSelector對象,用來實現(xiàn)一個日歷形式的日期輸入框。
{
var myDate=new Date();
this.year=myDate.getFullYear(); //定義year屬性,年份,默認值為當前系統(tǒng)年份。
this.month=myDate.getMonth()+1; //定義month屬性,月份,默認值為當前系統(tǒng)月份。
this.date=myDate.getDate(); //定義date屬性,日,默認值為當前系統(tǒng)的日。
this.inputName=''; //定義inputName屬性,即輸入框的name,默認值為空。注意:在同一頁中出現(xiàn)多個日期輸入框,不能有重復的name!
this.display=display; //定義display方法,用來顯示日期輸入框。
}
function display() //定義dateSelector的display方法,它將實現(xiàn)一個日歷形式的日期選擇框。
{
var week=new Array('日','一','二','三','四','五','六');
document.write("style type=text/css");
document.write(" .ds_font td,span { font: normal 12px 宋體; color: #000000; }");
document.write(" .ds_border { border: 1px solid #000000; cursor: hand; background-color: #DDDDDD }");
document.write(" .ds_border2 { border: 1px solid #000000; cursor: hand; background-color: #DDDDDD }");
document.write("/style");
var M=new String(this.month);
var d=new String(this.date);
if(M.length==1d.length==1){
document.write("input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-0"+this.month+"-0"+this.date+"' title=雙擊可進行編緝 ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly");}
else if(M.length==1d.length==2){
document.write("input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-0"+this.month+"-"+this.date+"' title=雙擊可進行編緝 ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly");}
else if(M.length==2d.length==1){
document.write("input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-"+this.month+"-0"+this.date+"' title=雙擊可進行編緝 ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly");}
else if(M.length==2d.length==2){
document.write("input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-"+this.month+"-"+this.date+"' title=雙擊可進行編緝 ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly");}
document.write("button style='width:60px;height:18px;font-size:12px;margin:1px;border:1px solid #A4B3C8;background-color:#DFE7EF;' type=button onclick=this.nextSibling.style.display='block' onfocus=this.blur()日期/button");
document.write("div style='position:absolute;display:none;text-align:center;width:0px;height:0px;overflow:visible' onselectstart='return false;'");
document.write(" div style='position:absolute;left:-60px;top:20px;width:142px;height:165px;background-color:#F6F6F6;border:1px solid #245B7D;' class=ds_font");
document.write(" table cellpadding=0 cellspacing=1 width=140 height=20 bgcolor=#CEDAE7 onmousedown='DS_x=event.x-parentNode.style.pixelLeft;DS_y=event.y-parentNode.style.pixelTop;setCapture();' onmouseup='releaseCapture();' onmousemove='dsMove(this.parentNode)' style='cursor:move;'");
document.write(" tr align=center");
document.write(" td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=subYear(this) title='減小年份'/td");
document.write(" td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=subMonth(this) title='減小月份'/td");
document.write(" td width=52%b"+this.year+"/bb年/bb"+this.month+"/bb月/b/td");
document.write(" td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=addMonth(this) title='增加月份'/td");
document.write(" td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=addYear(this) title='增加年份'/td");
document.write(" /tr");
document.write(" /table");
document.write(" table cellpadding=0 cellspacing=0 width=140 height=20 onmousedown='DS_x=event.x-parentNode.style.pixelLeft;DS_y=event.y-parentNode.style.pixelTop;setCapture();' onmouseup='releaseCapture();' onmousemove='dsMove(this.parentNode)' style='cursor:move;'");
document.write(" tr align=center");
for(i=0;i7;i++)
document.write(" td"+week[i]+"/td");
document.write(" /tr");
document.write(" /table");
document.write(" table cellpadding=0 cellspacing=2 width=140 bgcolor=#EEEEEE");
for(i=0;i6;i++)
{
document.write(" tr align=center");
for(j=0;j7;j++)
document.write(" td width=10% height=16 onmouseover=if(this.innerText!=''this.className!='ds_border2')this.className='ds_border' onmouseout=if(this.className!='ds_border2')this.className='' onclick=getValue(this,document.all('DS_"+this.inputName+"'))/td");
document.write(" /tr");
}
document.write(" /table");
document.write(" span style=cursor:hand onclick=this.parentNode.parentNode.style.display='none'【關(guān)閉】/span");
document.write(" /div");
document.write("/div");
dateShow(document.all("DS_"+this.inputName).nextSibling.nextSibling.childNodes[0].childNodes[2],this.year,this.month)
}
function subYear(obj) //減小年份
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
myObj[0].innerHTML=eval(myObj[0].innerHTML)-1;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}
function addYear(obj) //增加年份
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
myObj[0].innerHTML=eval(myObj[0].innerHTML)+1;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}
function subMonth(obj) //減小月份
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
var month=eval(myObj[2].innerHTML)-1;
if(month==0)
{
month=12;
subYear(obj);
}
myObj[2].innerHTML=month;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}
function addMonth(obj) //增加月份
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
var month=eval(myObj[2].innerHTML)+1;
if(month==13)
{
month=1;
addYear(obj);
}
myObj[2].innerHTML=month;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}
function dateShow(obj,year,month) //顯示各月份的日
{
var myDate=new Date(year,month-1,1);
var today=new Date();
var day=myDate.getDay();
var selectDate=obj.parentNode.parentNode.previousSibling.previousSibling.value.split('-');
var length;
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
length=31;
break;
case 4:
case 6:
case 9:
case 11:
length=30;
break;
case 2:
if((year%4==0)(year%100!=0)||(year%400==0))
length=29;
else
length=28;
}
for(i=0;iobj.cells.length;i++)
{
obj.cells[i].innerHTML='';
obj.cells[i].style.color='';
obj.cells[i].className='';
}
for(i=0;ilength;i++)
{
obj.cells[i+day].innerHTML=(i+1);
if(year==today.getFullYear()(month-1)==today.getMonth()(i+1)==today.getDate())
obj.cells[i+day].style.color='red';
if(year==eval(selectDate[0])month==eval(selectDate[1])(i+1)==eval(selectDate[2]))
obj.cells[i+day].className='ds_border2';
}
}
function getValue(obj,inputObj) //把選擇的日期傳給輸入框
{
var myObj=inputObj.nextSibling.nextSibling.childNodes[0].childNodes[0].cells[2].childNodes;
if(obj.innerHTML)
if(obj.innerHTML.length==1myObj[2].innerHTML.length==1)
inputObj.value=myObj[0].innerHTML+"-0"+myObj[2].innerHTML+"-0"+obj.innerHTML;
else if(obj.innerHTML.length==1myObj[2].innerHTML.length==2)
inputObj.value=myObj[0].innerHTML+"-"+myObj[2].innerHTML+"-0"+obj.innerHTML;
else if(obj.innerHTML.length==2myObj[2].innerHTML.length==1)
inputObj.value=myObj[0].innerHTML+"-0"+myObj[2].innerHTML+"-"+obj.innerHTML;
else if(obj.innerHTML.length==2myObj[2].innerHTML.length==2)
inputObj.value=myObj[0].innerHTML+"-"+myObj[2].innerHTML+"-"+obj.innerHTML;
inputObj.nextSibling.nextSibling.style.display='none';
for(i=0;iobj.parentNode.parentNode.parentNode.cells.length;i++)
obj.parentNode.parentNode.parentNode.cells[i].className='';
obj.className='ds_border2'
}
function dsMove(obj) //實現(xiàn)層的拖移
{
if(event.button==1)
{
var X=obj.clientLeft;
var Y=obj.clientTop;
obj.style.pixelLeft=X+(event.x-DS_x);
obj.style.pixelTop=Y+(event.y-DS_y);
}
}
/***調(diào)用代碼**
script language=javascript
var myDate=new dateSelector();
myDate.year=1900;//morenqiri
myDate.inputName='date'; //
myDate.display();
/script
*/
/*
題目:輸出任意年份任意月份的日歷表(公元后)
思路:
1.已知1年1月1日是星期日,1?%?7?=?1?對應的是星期日,2?%?7?=?2?對應的是星期一,以此類推;
2.計算當年以前所有天數(shù)+當年當月1號之前所有天數(shù);
a.年份分平年閏年,平年365天,閏年366天;
b.閏年的判斷方法year?%?400?==?0?||?(year?%?100?!=?0??year?%?4?==?0)若為真,則為閏年否則為平年;
c.定義平年/閏年數(shù)組,包含各月天數(shù);
d.遍歷數(shù)組求和,計算當年當月前總天數(shù);
e.當年以前所有天數(shù)+當年當月前總天數(shù)+1即為1年1月1日到當年當月1日的總天數(shù);
3.總天數(shù)對7取模,根據(jù)結(jié)果判斷當月1號是星期幾,輸出空白區(qū)域;
4.輸出當月日歷表,逢星期六換行
*/
import?java.util.Scanner;
class?FindMonthList?{
public?static?void?main(String[]?args){
Scanner?sc?=?new?Scanner(System.in);
System.out.println("請輸入年份:");
int?year?=?sc.nextInt();????????????//年份
if?(year??1)?{????????????????????????//判斷非法輸入年份
System.out.println("輸入錯誤!");
return;
}
System.out.println("請輸入月份:");
int?month?=?sc.nextInt();????????????//月份
if?(month??1?||?month??12)?{????????//判斷非法輸入月份
System.out.println("輸入錯誤!");
return;
}
//輸出表頭
System.out.println("-------"?+?year?+?"?年?"?+?month?+?"?月?"?+?"-------");
System.out.println();
System.out.println("日??一??二??三??四??五??六");
//計算當前年份以前所有天數(shù)beforeYearTotalDay;每4年一個閏年,閏年366天,平年365天
int?beforeYearTotalDay?=?((year?-?1)?/?4?*?366)?+?(year-1?-?((year?-?1)?/?4))?*?365;
int[]?arrLeapYear?=?{0,31,29,31,30,31,30,31,31,30,31,30,31};????//閏年各月天數(shù)????int數(shù)組
int[]?arrNormalYear?=?{0,31,28,31,30,31,30,31,31,30,31,30,31};????//平年各月天數(shù)????int數(shù)組
int?beforeMonthTotalDay?=?0;????????????????????????????????????//定義本年當月之前月份的總天數(shù)
if?(year?%?400?==?0?||?(year?%?100?!=?0??year?%?4?==?0))?{????//判斷當前年份是否是閏年
for?(int?i?=?0?;?i??month?;?i?++?)?{????//for循環(huán)計算當月之前總天數(shù)
//計算當前月份之前的所有天數(shù)
beforeMonthTotalDay?=?beforeMonthTotalDay?+?arrLeapYear[i];
}
//判斷當月1日是星期幾
int?totalDay?=?beforeYearTotalDay?+?beforeMonthTotalDay?+?1;
int?week?=?totalDay?%?7;//已知1年1月1日是星期日,即模7得1對應的是星期日
for?(int?i?=?0?;?i??(week?-?1?+?7)?%?7?;?i?++)?{????//如果寫成i??(week-1)會出現(xiàn)i-1的情況
System.out.print("????");//輸出開頭空白
}
for?(int?i?=?1?;i?=?arrLeapYear[month]?;i?++?)?{????//for循環(huán)輸出各月天數(shù)
System.out.print(i?+?"??");
if?(i??10?)?{????????//小于10的數(shù)補一個空格,以便打印整齊
System.out.print("?");
}
if?(i?%?7?==?((7-(week?-?1))?%?7?)?||?i?==?arrLeapYear[month])?{//每逢星期六/尾數(shù)換行
System.out.println();
}
}
}?else?{????????//不是閏年就是平年
for?(int?i?=?0?;?i??month?;?i?++?)?{????//for循環(huán)計算出當月之前月份總天數(shù)
beforeMonthTotalDay?=?beforeMonthTotalDay?+?arrNormalYear[i];
}
//判斷當月1日是星期幾
int?totalDay?=?beforeYearTotalDay?+?beforeMonthTotalDay?+?1;
int?week?=?totalDay?%?7;//已知1年1月1日是星期日,即模7得1對應的是星期日
for?(int?i?=?0?;?i??(week?-?1?+?7)?%?7?;?i?++)?{????//如果寫成i??(week-1)會出現(xiàn)i-1的情況
System.out.print("????");//輸出開頭空白
}
for?(int?i?=?1?;i?=?arrNormalYear[month]?;i?++?)?{//for循環(huán)輸出各月天數(shù)
System.out.print(i?+?"??");
if?(i??10?)?{????????????//小于10的數(shù)補一個空格,以便打印整齊
System.out.print("?");
}
if?(i?%?7?==?((7-(week?-?1))?%?7?)?||?i?==?arrNormalYear[month])?{//每逢星期六/尾數(shù)換行
System.out.println();
}
}
}
}
}
顯示效果:
當前標題:java萬年歷代碼視頻 萬年歷java編程
網(wǎng)站網(wǎng)址:http://www.yijiale78.com/article20/hhijco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、自適應網(wǎng)站、動態(tài)網(wǎng)站、網(wǎng)站內(nèi)鏈、網(wǎng)站排名、App設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)