Initial commit
This commit is contained in:
22
src/test/java/sample/HalfYearTest.java
Normal file
22
src/test/java/sample/HalfYearTest.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.*;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 半年示例
|
||||
*/
|
||||
public class HalfYearTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
SolarHalfYear halfYear = new SolarHalfYear();
|
||||
System.out.println(halfYear);
|
||||
System.out.println(halfYear.toFullString());
|
||||
|
||||
for(SolarMonth month:halfYear.getMonths()){
|
||||
System.out.println(month.toFullString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
26
src/test/java/sample/LunarTest.java
Normal file
26
src/test/java/sample/LunarTest.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Lunar;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 农历示例
|
||||
*/
|
||||
public class LunarTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//今天
|
||||
Lunar date = new Lunar();
|
||||
//输出阴历信息
|
||||
System.out.println(date.toFullString());
|
||||
//输出阳历信息
|
||||
System.out.println(date.getSolar().toFullString());
|
||||
System.out.println();
|
||||
//指定阴历的某一天
|
||||
date = new Lunar(1986,4,21);
|
||||
System.out.println(date.toFullString());
|
||||
System.out.println(date.getSolar().toFullString());
|
||||
}
|
||||
|
||||
}
|
||||
26
src/test/java/sample/MonthTest.java
Normal file
26
src/test/java/sample/MonthTest.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.SolarMonth;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 月份示例
|
||||
*/
|
||||
public class MonthTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//下个月
|
||||
SolarMonth month = new SolarMonth().next(1);
|
||||
//遍历每一天
|
||||
for(Solar d:month.getDays()){
|
||||
//输出阳历信息
|
||||
System.out.println(d.toFullString());
|
||||
//输出阴历信息
|
||||
System.out.println(d.getLunar().toFullString());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
23
src/test/java/sample/SeasonTest.java
Normal file
23
src/test/java/sample/SeasonTest.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.SolarMonth;
|
||||
import com.nlf.calendar.SolarSeason;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 季度示例
|
||||
*/
|
||||
public class SeasonTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
SolarSeason season = new SolarSeason();
|
||||
System.out.println(season);
|
||||
System.out.println(season.toFullString());
|
||||
|
||||
for(SolarMonth month:season.getMonths()){
|
||||
System.out.println(month.toFullString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
26
src/test/java/sample/SolarTest.java
Normal file
26
src/test/java/sample/SolarTest.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Solar;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 阳历示例
|
||||
*/
|
||||
public class SolarTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//阳历今天
|
||||
Solar date = new Solar();
|
||||
//输出阳历信息
|
||||
System.out.println(date.toFullString());
|
||||
//输出阴历信息
|
||||
System.out.println(date.getLunar().toFullString());
|
||||
System.out.println();
|
||||
//指定某个阳历日期
|
||||
date = new Solar(1986,5,29);
|
||||
System.out.println(date.toFullString());
|
||||
System.out.println(date.getLunar().toFullString());
|
||||
}
|
||||
|
||||
}
|
||||
28
src/test/java/sample/WeekTest.java
Normal file
28
src/test/java/sample/WeekTest.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.SolarWeek;
|
||||
import com.nlf.calendar.util.SolarUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 周示例
|
||||
*/
|
||||
public class WeekTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//一周的开始从星期一开始计
|
||||
SolarWeek week = new SolarWeek(1);
|
||||
System.out.println(week);
|
||||
System.out.println(week.toFullString());
|
||||
|
||||
System.out.println("本月共几周:"+ SolarUtil.getWeeksOfMonth(week.getYear(),week.getMonth(),1));
|
||||
System.out.println("本周第一天:"+week.getFirstDay());
|
||||
//遍历本周的每一天
|
||||
for(Solar day:week.getDays()){
|
||||
System.out.println(day);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
src/test/java/sample/YearTest.java
Normal file
46
src/test/java/sample/YearTest.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package sample;
|
||||
|
||||
import com.nlf.calendar.Lunar;
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.SolarMonth;
|
||||
import com.nlf.calendar.SolarYear;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 年份示例,我们来做一个日历吧
|
||||
*/
|
||||
public class YearTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//明年
|
||||
SolarYear year = new SolarYear().next(1);
|
||||
System.out.println("==="+year.getYear()+"年===");
|
||||
//遍历明年的每个月
|
||||
for(SolarMonth m:year.getMonths()){
|
||||
System.out.println("---"+m.getMonth()+"月---");
|
||||
//遍历当月的每一天
|
||||
for(Solar d:m.getDays()){
|
||||
//获取阴历
|
||||
Lunar lunar = d.getLunar();
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(d.getDay()<10?"0":"");
|
||||
s.append(d.getDay());
|
||||
s.append(" ");
|
||||
s.append(lunar.getMonthInChinese());
|
||||
s.append("月");
|
||||
s.append(lunar.getDayInChinese());
|
||||
s.append(" ");
|
||||
s.append("星期");
|
||||
s.append(d.getWeekInChinese());
|
||||
s.append(" ");
|
||||
s.append(d.getFestivals());
|
||||
s.append(lunar.getFestivals());
|
||||
s.append(lunar.getJie());
|
||||
s.append(lunar.getQi());
|
||||
System.out.println(s.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user