Java核心技术 4.2.3代码练习
package main;
import java.time.LocalDate;
public class CalendarTest {
private static void printCalendar(LocalDate now) {
String header = "Mon Tue Wed Thu Fri Sat Sun";
System.out.println(header);
LocalDate firstDayOfMonth = now.withDayOfMonth(1);
LocalDate lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth());
LocalDate firstDayOfFirstWeek = firstDayOfMonth.minusDays(firstDayOfMonth.getDayOfWeek().getValue() - 1);
LocalDate current = firstDayOfFirstWeek;
while (current.compareTo(lastDayOfMonth) <= 0) {
String temp;
if (current.isBefore(firstDayOfMonth)) {
temp = " ";
} else {
temp = String.format("%3d", current.getDayOfMonth());
}
if (current.isEqual(now)) {
temp = temp + "*";
} else {
temp = temp + " ";
}
System.out.print(temp);
if (current.getDayOfWeek().getValue() == 7) {
System.out.print("\n");
}
current = current.plusDays(1);
}
}
public static void main(String[] args) {
LocalDate now = LocalDate.of(2021, 10, 24);
printCalendar(now);
}
}
评论列表,共 3 条评论
Hello,
* FTP MP3 server and direct download of everything: https://www.0daymusic.org/premium.php
* Resellers: PayPal, VISA, Bank Transfer, Bitcoin, Mastercard, Amazon Pay, WebMoney...
* FTPtxt-16 software: https://www.0daymusic.org/FTPtxt for text search.
* Server capacity: 440 TB MP3, FLAC, labels, music videos.
* Supports: FTP, FTPS (File Transfer Protocol Secure), SFTP, and HTTP, HTTPS.
* Daily updates: 30-100 GB, 300-2000 albums, web, promo, CDM, CDR, CDS, EP, LP, vinyl...
* Unlimited download speed.
* Files available anytime.
* Over 17 years of archive.
* Total server speed: 1 Gbps.
* User-friendly. Most genres are sorted by day.
0-DAY TEAM
<a href=http://cialis.lat/discover-the-best-prices-for-cialis>generic cialis online pharmacy</a> Edema come risultato di CHF il farmaco ГЁ usato qui come monoterapia e come parte di un trattamento combinato
<a href=http://cialis.lat/discover-the-best-prices-for-cialis>where to buy cialis</a> Had one to day, no pain meds, no preparation or warning worst pain of my life, couldn t stop crying afterward for hours