Skip to content

Commit 8f3d617

Browse files
committed
initial
1 parent 5dda01c commit 8f3d617

17 files changed

Lines changed: 2182 additions & 9 deletions

pom.xml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,48 @@
301301
</exclusions>
302302
</dependency>
303303

304+
<dependency>
305+
<groupId>com.sun.jersey</groupId>
306+
<artifactId>jersey-server</artifactId>
307+
<version>1.9</version>
308+
</dependency>
309+
310+
<!--操作office的poi包-->
311+
<dependency>
312+
<groupId>org.apache.poi</groupId>
313+
<artifactId>poi</artifactId>
314+
<version>3.10-FINAL</version>
315+
</dependency>
316+
<dependency>
317+
<groupId>org.apache.poi</groupId>
318+
<artifactId>poi-ooxml</artifactId>
319+
<version>3.10-FINAL</version>
320+
</dependency>
321+
<dependency>
322+
<groupId>org.apache.poi</groupId>
323+
<artifactId>poi-ooxml-schemas</artifactId>
324+
<version>3.10-FINAL</version>
325+
</dependency>
326+
<dependency>
327+
<groupId>org.apache.xmlbeans</groupId>
328+
<artifactId>xmlbeans</artifactId>
329+
<version>2.3.0</version>
330+
</dependency>
331+
332+
<!-- word/html/xml转Pdf -->
333+
<!-- add all iText 7 Community modules -->
334+
<dependency>
335+
<groupId>com.itextpdf</groupId>
336+
<artifactId>itext7-core</artifactId>
337+
<version>7.0.4</version>
338+
<type>pom</type>
339+
</dependency>
340+
<dependency>
341+
<groupId>junit</groupId>
342+
<artifactId>junit</artifactId>
343+
<version>4.12</version>
344+
</dependency>
345+
304346

305347
</dependencies>
306348

@@ -362,8 +404,9 @@
362404
<resource>
363405
<directory>src/main/resources</directory>
364406
<includes>
365-
<include>**/*.xml</include>
366-
<include>**/*.properties</include>
407+
<!--<include>**/*.xml</include>-->
408+
<!--<include>**/*.properties</include>-->
409+
<include>**/*.*</include>
367410
</includes>
368411
</resource>
369412
<resource>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.decom.chunks.annotation;
2+
3+
/**
4+
* Created by Administrator on 2017/10/16.
5+
*/
6+
7+
import java.lang.annotation.*;
8+
9+
/**
10+
* 元注解,jkd 5.0带有4个标准元注解
11+
* 1.@Target
12+
* 指注解的应用范围
13+
* 取值(ElementType)有:
14+
*     1.CONSTRUCTOR:用于描述构造器
15+
*     1.CONSTRUCTOR:用于描述构造器
16+
*     2.FIELD:用于描述域
17+
*     3.LOCAL_VARIABLE:用于描述局部变量
18+
*     4.METHOD:用于描述方法
19+
*     5.PACKAGE:用于描述包
20+
*     6.PARAMETER:用于描述参数
21+
*     7.TYPE:用于描述类、接口(包括注解类型) 或enum声明
22+
*
23+
* 2.@Retention
24+
* 指注解的生命期
25+
* 取值(RetentionPoicy)有:
26+
*     1.SOURCE:在源文件中有效(即源文件保留)
27+
*     2.CLASS:在class文件中有效(即class保留)
28+
*     3.RUNTIME:在运行时有效(即运行时保留)
29+
*
30+
* 3.@Documented
31+
* 指注解是否可以有文档化
32+
* Documented是一个标记注解,没有成员;
33+
* 标记是否可被javadoc此类的工具文档化
34+
*
35+
* 4.@Inherited
36+
* 定义该注释和子类的关系,即是否允许子类继承该注解
37+
*
38+
* 自定义注解类编写的一些规则:
39+
* 1. Annotation型定义为@interface, 所有的Annotation会自动继承java.lang.Annotation这一接口,并且不能再去继承别的类或是接口.
40+
* 定义注解格式:
41+
*  public @interface 注解名 {定义体}
42+
* 2. 参数成员只能用public或默认(default)这两个访问权修饰
43+
* 3. 参数成员只能用基本类型byte,short,char,int,long,float,double,boolean八种基本数据类型和String、Enum、Class、
44+
* Annotation等数据类型,以及这一些类型的数组.
45+
* 4. 要获取类方法和字段的注解信息,必须通过Java的反射技术来获取 Annotation对象,因为你除此之外没有别的获取注解对象的方法
46+
* 5. 注解也可以没有定义成员, 不过这样注解就没啥用了
47+
* PS:自定义注解需要使用到元注解
48+
*
49+
*/
50+
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
51+
@Retention(RetentionPolicy.RUNTIME)
52+
@Inherited
53+
@Documented
54+
public @interface CustomAnnotation {
55+
public String author() default "micropc";
56+
String date();
57+
int version() default 1;
58+
String comments();
59+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.decom.chunks.annotation;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* Created by Administrator on 2017/10/16.
8+
*
9+
* @author Administrator
10+
*/
11+
public class CustomAnnotationTest {
12+
public static void main(String[] args) {
13+
genericTest();
14+
}
15+
16+
@Override
17+
@CustomAnnotation(author = "admin au", date = "oct 16 2017", version = 1, comments = "")
18+
public String toString() {
19+
return "override tostring methord!";
20+
}
21+
22+
@CustomAnnotation(date = "oct 16 2017", comments = "deprecated methord!")
23+
public static void oldMethord(){
24+
System.out.println("old methord, do not use it!");
25+
}
26+
27+
@CustomAnnotation(author = "micro admin", date = "oct 16 2017", comments = "generic test")
28+
public static void genericTest(){
29+
List list = new ArrayList();
30+
list.add("abc");
31+
oldMethord();
32+
}
33+
34+
}

src/main/java/com/decom/chunks/CalcRatioResult.java renamed to src/main/java/com/decom/chunks/economic/CalcRatioResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.decom.chunks;
1+
package com.decom.chunks.economic;
22

33
public class CalcRatioResult {
44
/**

src/main/java/com/decom/chunks/CompoundInterest.java renamed to src/main/java/com/decom/chunks/economic/CompoundInterest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.decom.chunks;
1+
package com.decom.chunks.economic;
22

33
import java.text.DecimalFormat;
44
import java.util.Currency;
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package com.decom.chunks.java8DateTime;
2+
3+
import junit.framework.TestCase;
4+
import org.junit.Test;
5+
6+
import java.time.*;
7+
import java.time.format.DateTimeFormatter;
8+
import java.time.format.TextStyle;
9+
import java.time.temporal.ChronoUnit;
10+
import java.util.Locale;
11+
import java.util.Set;
12+
13+
/**
14+
* Created by Administrator on 2017/10/30.
15+
*
16+
* java 8 包含了一套全新的日期时间类,主要有:
17+
* 1、Instant——代表时间戳
18+
* 2、LocalDate——不包含具体时间(指HH:mm:ss)的日期
19+
* 3、LocalTime——不包含日期(指yyyy-MM-dd)的时间
20+
* 4、LocalDateTime——包含日期和时间,但不包含时区
21+
* 5、ZonedDateTime——包含完整时区的日期、时间
22+
*/
23+
public class DataTimeUtil extends TestCase {
24+
25+
//LocalDate
26+
@Test
27+
public void testLocalDateTest() {
28+
LocalDate today = LocalDate.now();
29+
System.out.println("今天日期是:" + today);
30+
System.out.println("今天的年份是:" + today.getYear());
31+
System.out.println("今天的月份是:" + today.getMonth().getValue());
32+
System.out.println("今天是所在月份的几号:" + today.getDayOfMonth());
33+
System.out.println("今天是星期几:" + today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
34+
System.out.println("今天是一年中的第多少天:" + today.getDayOfYear());
35+
36+
LocalDateTime localDateTime = today.atTime(LocalTime.of(18, 20, 30));
37+
System.out.println("在指定日期后加上时间后的日期时间为:" + localDateTime);
38+
39+
//日期计算
40+
LocalDate previousDate = LocalDate.of(2016, 8, 19);
41+
// today = today.minus(previousDate);
42+
43+
LocalDate minusYears = today.minus(1000, ChronoUnit.YEARS); //第2个参数是要减云的时间的单位,为枚举值
44+
System.out.println("当前日期减去1000年后的日期为:" + minusYears);
45+
46+
LocalDate minusDays = today.minusDays(10);
47+
System.out.println("当前日期减去10天后的日期为:" + minusDays);
48+
49+
LocalDate plusDays = today.plusDays(10);
50+
System.out.println("当前加10天后的日期为:" + plusDays);
51+
52+
}
53+
54+
//测试构造指定日期
55+
@Test
56+
public void testCreateLocalDate() {
57+
LocalDate parseLocalDate = LocalDate.of(2000, 5, 10);
58+
System.out.println("构造的日期为:" + parseLocalDate);
59+
parseLocalDate = LocalDate.of(2000, Month.APRIL, 8);
60+
System.out.println("月份采用枚举构造日期:" + parseLocalDate);
61+
parseLocalDate = LocalDate.parse("2001-01-19");
62+
System.out.println("1位月份数字前补0日期:" + parseLocalDate);
63+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy,MM,dd");
64+
parseLocalDate = LocalDate.parse("2000,10,10", formatter); //如果日期参数为2000-10-10,会报错
65+
System.out.println("指定日期字符串格式,构造的日期为:" + parseLocalDate);
66+
}
67+
68+
//测试日期比较
69+
@Test
70+
public void testCompareLocalDate() {
71+
LocalDate previousLocalDate = LocalDate.of(2008, 9, 10);
72+
LocalDate now = LocalDate.now();
73+
if(previousLocalDate.isEqual(now)) {
74+
System.out.println("指定日期:" + previousLocalDate + "和当前日期" + now + "相等");
75+
} else {
76+
System.out.println("指定日期:" + previousLocalDate + "和当前日期" + now + "不相等");
77+
}
78+
if(previousLocalDate.isLeapYear()) {//是否是闰年
79+
System.out.println("指定日期:" + previousLocalDate + "是闰年");
80+
} else {
81+
System.out.println("指定日期:" + previousLocalDate + "不是闰年");
82+
}
83+
if(previousLocalDate.isBefore(now)) {
84+
System.out.println("指定日期:" + previousLocalDate + "早于当前日期" + now);
85+
} else {
86+
System.out.println("指定日期:" + previousLocalDate + "晚于当前日期" + now);
87+
}
88+
}
89+
90+
//重复事件检查
91+
@Test
92+
public void testCheckBirthday() {
93+
LocalDate dateOfBirth = LocalDate.of(1990, 8, 10); //出生日期
94+
MonthDay monthDay = MonthDay.of(dateOfBirth.getMonth(), dateOfBirth.getDayOfMonth());//生日
95+
96+
LocalDate now = LocalDate.now();
97+
MonthDay todayMonthDay = MonthDay.from(now);
98+
99+
if(monthDay.equals(todayMonthDay)) {
100+
System.out.println("今天是您的生日");
101+
} else {
102+
System.out.println("今天不是您的生日");
103+
}
104+
}
105+
106+
//LocalTime,当前时间,不包含日期
107+
@Test
108+
public void testLocalTime() {
109+
LocalTime localTime = LocalTime.now();
110+
System.out.println("当前时间是:" + localTime);
111+
112+
LocalDateTime localDateTime = localTime.atDate(LocalDate.of(2000, 10, 10));
113+
System.out.println("在localtime基础上加上指定日期后的时期时间为:" + localDateTime);
114+
}
115+
116+
//clock 时钟,获取当前瞬时时间、日期(和时区有关),取代System.currentTimelnMillis()和TimeZone.getDefault()
117+
@Test
118+
public void testClock() {
119+
Clock nowMillis = Clock.systemUTC();
120+
System.out.println("当前毫秒是:" + nowMillis.millis());
121+
122+
Clock nowZone = Clock.systemDefaultZone();
123+
// System.out.println("当前时区是:" + nowZone.getZone().getDisplayName(TextStyle.FULL, Locale.CHINA));
124+
System.out.println("当前时区是:" + nowZone.getZone());
125+
126+
// Clock nowTickMinutes = Clock.tickMinutes(ZoneId.of("Asia/Shanghai"));
127+
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
128+
Clock nowTickMinutes = Clock.tickMinutes(ZoneId.systemDefault());
129+
130+
System.out.println("当前分钟是:" + nowTickMinutes.toString());
131+
132+
}
133+
134+
}

0 commit comments

Comments
 (0)