|
@@ -0,0 +1,172 @@
|
|
|
+package ieven.server.webapp;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class Test {
|
|
|
+ public static void main(String[] args) {
|
|
|
+ // List<String> strings = FileUtil.readLines("f://test1.txt", "utf-8");
|
|
|
+ /*for (String string : strings) {
|
|
|
+ // System.out.println(string.substring(0, 10));
|
|
|
+ Date date = DateUtil.parse(string);
|
|
|
+ StringBuilder stringBuilder = new StringBuilder("");
|
|
|
+ stringBuilder.append(date12(date));
|
|
|
+ stringBuilder.append(date13(date));
|
|
|
+ stringBuilder.append(date14(date));
|
|
|
+ System.out.println(stringBuilder);
|
|
|
+ }*/
|
|
|
+ List<String> strings = FileUtil.readLines("f://test2.txt", "utf-8");
|
|
|
+ for (String string : strings) {
|
|
|
+ if (StringUtils.isBlank(string)) {
|
|
|
+ System.out.println("");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int end = string.indexOf("市");
|
|
|
+ if (end == -1) {
|
|
|
+ end = string.indexOf("区");
|
|
|
+ int end2 = string.indexOf("县");
|
|
|
+ if (end2 > 0) {
|
|
|
+ end = end2;
|
|
|
+ }
|
|
|
+ if (end == -1) {
|
|
|
+ end = string.indexOf("县");
|
|
|
+ if (end == -1) {
|
|
|
+ end = string.length() - 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String substring = string.substring(0, end + 1);
|
|
|
+ System.out.println(substring);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date1(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-02-03");
|
|
|
+ Date date2 = DateUtil.parse("2021-02-06");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "立春";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date2(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-02-18");
|
|
|
+ Date date2 = DateUtil.parse("2021-02-21");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "雨水";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date3(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-03-05");
|
|
|
+ Date date2 = DateUtil.parse("2021-03-08");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "惊蛰";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date4(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-03-20");
|
|
|
+ Date date2 = DateUtil.parse("2021-03-23");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "春分";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date5(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-04-04");
|
|
|
+ Date date2 = DateUtil.parse("2021-04-07");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "清明";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date6(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-04-19");
|
|
|
+ Date date2 = DateUtil.parse("2021-04-22");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "谷雨";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date7(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-05-05");
|
|
|
+ Date date2 = DateUtil.parse("2021-05-08");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "立夏";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date8(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-05-20");
|
|
|
+ Date date2 = DateUtil.parse("2021-05-28");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "小满";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date9(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-06-05");
|
|
|
+ Date date2 = DateUtil.parse("2021-06-08");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "芒种";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date10(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-06-21");
|
|
|
+ Date date2 = DateUtil.parse("2021-06-23");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "夏至";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date11(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2021-07-06");
|
|
|
+ Date date2 = DateUtil.parse("2021-07-09");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "小暑";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date12(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2022-10-08");
|
|
|
+ Date date2 = DateUtil.parse("2022-10-10");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "寒露";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date13(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2022-10-23");
|
|
|
+ Date date2 = DateUtil.parse("2022-10-25");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "霜降";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String date14(Date date) {
|
|
|
+ Date date1 = DateUtil.parse("2022-11-07");
|
|
|
+ Date date2 = DateUtil.parse("2022-11-09");
|
|
|
+ if (date.after(date1) && date.before(date2)) {
|
|
|
+ return "立冬";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+}
|