import java
import java
import java
public class Test {
public static void main(String[] args) {
List<Integer> links = new ArrayList<Integer>();
links
links
links
links
links
links
links
links
links
links
// 采用當月的方式進行構造
Nil
System
}
}
class Nil
/**
* 生成日歷的 Calendar
*/
private Calendar calendar;
/**
* 有鏈接的日期
*/
private List<Integer> links;
private static String TABLE_START =
private static String TABLE_END =
private static String TR_START =
private static String TR_END =
private static String TD_START =
private static String TD_END =
private static String TD_BLANK = TD_START +
/**
* 鏈接字符串的常量
*/
private static String LINK =
/**
* 構造當月的日歷
* @param links 需要帶有鏈接的日期
*/
public Nil
this(Calendar
}
/**
* 構造指定日期月份的日歷
* @param calendar 指定日期
* @param links 需要帶有鏈接的日期
*/
public Nil
calendar
this
this
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb
sb
int total =
// 若非周日時
for(int k = calendar
appendBlank(sb);
}
for(int i =
if((total
sb
}
appendDate(sb
total++;
}
// 最後的日期如果不是周六
while((total
appendBlank(sb);
total++;
}
sb
sb
return sb
}
private void appendBlank(StringBuffer sb) {
sb
}
private void appendDate(StringBuffer sb
sb
if(ntains(date)) {
sb
} else {
sb
}
sb
}
}
import java
import java
import java
public class Test {
public static void main(String[] args) {
List<Integer> links = new ArrayList<Integer>();
links
links
links
links
links
links
links
links
links
links
// 采用當月的方式進行構造
Nil
System
}
}
class Nil
/**
* 生成日歷的 Calendar
*/
private Calendar calendar;
/**
* 有鏈接的日期
*/
private List<Integer> links;
private static String TABLE_START =
private static String TABLE_END =
private static String TR_START =
private static String TR_END =
private static String TD_START =
private static String TD_END =
private static String TD_BLANK = TD_START +
/**
* 鏈接字符串的常量
*/
private static String LINK =
/**
* 構造當月的日歷
* @param links 需要帶有鏈接的日期
*/
public Nil
this(Calendar
}
/**
* 構造指定日期月份的日歷
* @param calendar 指定日期
* @param links 需要帶有鏈接的日期
*/
public Nil
calendar
this
this
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb
sb
int total =
// 若非周日時
for(int k = calendar
appendBlank(sb);
}
for(int i =
if((total
sb
}
appendDate(sb
total++;
}
// 最後的日期如果不是周六
while((total
appendBlank(sb);
total++;
}
sb
sb
return sb
}
private void appendBlank(StringBuffer sb) {
sb
}
private void appendDate(StringBuffer sb
sb
if(ntains(date)) {
sb
} else {
sb
}
sb
}
}
運行結果為
<table width=
<tr>
<td> </td>
<td> </td>
<td>
<td>
<td><a >
<td>
<td>
</tr>
<tr>
<td><a >
<td>
<td>
<td><a >
<td>
<td>
<td><a >
</tr>
<tr>
<td>
<td>
<td><a >
<td>
<td>
<td><a >
<td>
</tr>
<tr>
<td>
<td><a >
<td>
<td>
<td><a >
<td>
<td>
</tr>
<tr>
<td><a >
<td>
<td>
<td><a >
<td>
<td> </td>
<td> </td>
<tr>
<table>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26120.html