Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b09d1ef
commit fcf1cfd
Showing
27 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Flink CEP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
flink-learning-common/src/main/java/com/zhisheng/common/utils/DateUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package com.zhisheng.common.utils; | ||
|
||
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.joda.time.format.DateTimeFormat; | ||
import org.joda.time.format.DateTimeFormatter; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* blog:http://www.54tianzhisheng.cn/ | ||
* 微信公众号:zhisheng | ||
*/ | ||
public class DateUtil { | ||
|
||
public static DateTimeFormatter YYYY_MM_DD = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
public static DateTimeFormatter YYYYMMDD = DateTimeFormat.forPattern("yyyyMMdd"); | ||
public static DateTimeFormatter YYYYMMDDHHMMSS = DateTimeFormat.forPattern("yyyyMMddHHmmss"); | ||
public static DateTimeFormatter YYYY_MM_DD_HH_MM_SS = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); | ||
public static DateTimeFormatter YYYY_MM_DD_HH_MM_SS_0 = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.0"); | ||
public static DateTimeFormatter YYYY_MM_DD_HH_MM = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); | ||
public static DateTimeFormatter YYYYMMDD_HH_MM_SS = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss"); | ||
|
||
|
||
public static String format(Date date, DateTimeFormatter dateFormatter) { | ||
DateTime dateTime = new DateTime(date); | ||
return dateTime.toString(dateFormatter); | ||
} | ||
|
||
public static String format(Date date, DateTimeZone timeZone, DateTimeFormatter dateFormatter) { | ||
DateTime dateTime = new DateTime(date, timeZone); | ||
return dateTime.toString(dateFormatter); | ||
} | ||
|
||
public static String format(long timeStamp, DateTimeFormatter dateFormatter) { | ||
return format(timeStamp, "Asia/Shanghai", dateFormatter); | ||
} | ||
|
||
public static String format(long timeStamp, String timeZoneId, DateTimeFormatter dateFormatter) { | ||
DateTimeZone timeZone = DateTimeZone.forID(timeZoneId); | ||
DateTime dateTime = new DateTime(timeStamp, timeZone); | ||
return dateTime.toString(dateFormatter); | ||
} | ||
|
||
/** | ||
* 格式化日期 | ||
* | ||
* @param time | ||
* @param dateFormatter | ||
* @return | ||
*/ | ||
public static long format(String time, DateTimeFormatter dateFormatter) { | ||
if (YYYY_MM_DD_HH_MM_SS_0.equals(dateFormatter)) { | ||
return YYYY_MM_DD_HH_MM_SS_0.parseMillis(time); | ||
} else if (YYYY_MM_DD_HH_MM_SS.equals(dateFormatter)) { | ||
return YYYY_MM_DD_HH_MM_SS.parseMillis(time); | ||
} else if (YYYY_MM_DD_HH_MM.equals(dateFormatter)) { | ||
return YYYY_MM_DD_HH_MM.parseMillis(time); | ||
} else if (YYYY_MM_DD.equals(dateFormatter)) { | ||
return YYYY_MM_DD.parseMillis(time); | ||
} | ||
return YYYY_MM_DD_HH_MM_SS.parseMillis(time); | ||
} | ||
|
||
public static long format(Date date) { | ||
return YYYY_MM_DD_HH_MM_SS.parseMillis(format(date, YYYY_MM_DD_HH_MM_SS)); | ||
} | ||
|
||
|
||
/** | ||
* 判断时间是否有效 | ||
* | ||
* @param value | ||
* @param formatter | ||
* @return | ||
*/ | ||
public static Boolean isValidDate(String value, DateTimeFormatter formatter) { | ||
try { | ||
formatter.parseDateTime(value); | ||
return true; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* 根据传入值的时间字符串和格式,输出Date类型 | ||
* | ||
* @param value | ||
* @param formatter | ||
* @return | ||
*/ | ||
public static Date toDate(String value, DateTimeFormatter formatter) { | ||
return formatter.parseDateTime(value).toDate(); | ||
} | ||
|
||
|
||
/** | ||
* 获取当天的开始时间的字符串 | ||
* | ||
* @param date 当天日期 | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtStartOfDay(Date date, DateTimeFormatter formatter) { | ||
return new DateTime(date).withTimeAtStartOfDay().toString(formatter); | ||
} | ||
|
||
/** | ||
* 获取当天的开始时间的字符串 | ||
* | ||
* @param date 当天日期 | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtStartOfDay(DateTime date, DateTimeFormatter formatter) { | ||
return date.withTimeAtStartOfDay().toString(formatter); | ||
} | ||
|
||
/** | ||
* 获取当天的结束时间的字符串 | ||
* | ||
* @param date 当天日期 | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtEndOfDay(Date date, DateTimeFormatter formatter) { | ||
return new DateTime(date).withTimeAtStartOfDay().plusDays(1).minusSeconds(1).toString(formatter); | ||
} | ||
|
||
/** | ||
* 获取当天的结束时间的字符串 | ||
* | ||
* @param date 当天日期 | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtEndOfDay(DateTime date, DateTimeFormatter formatter) { | ||
return date.withTimeAtStartOfDay().plusDays(1).minusSeconds(1).toString(formatter); | ||
} | ||
|
||
|
||
/** | ||
* 获取Now的开始时间的字符串 | ||
* 格式默认YYYYMMDDHHMMSS | ||
* | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtStartOfNow() { | ||
return DateTime.now().withTimeAtStartOfDay().toString(YYYYMMDDHHMMSS); | ||
} | ||
|
||
/** | ||
* 获取Now的结束时间的字符串 | ||
* 格式默认YYYYMMDDHHMMSS | ||
* | ||
* @return 当天的开始时间 | ||
*/ | ||
public static String withTimeAtEndOfNow() { | ||
return DateTime.now().withTimeAtStartOfDay().plusDays(1).minusSeconds(1).toString(YYYYMMDDHHMMSS); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
flink-learning-common/src/main/java/com/zhisheng/common/utils/StringUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.zhisheng.common.utils; | ||
|
||
/** | ||
* blog:http://www.54tianzhisheng.cn/ | ||
* 微信公众号:zhisheng | ||
*/ | ||
public class StringUtil { | ||
/** | ||
* 判空 | ||
* | ||
* @param str | ||
* @return | ||
*/ | ||
public static boolean isEmpty(String str) { | ||
return str == null || str.trim().length() == 0; | ||
} | ||
|
||
/** | ||
* 判非空 | ||
* | ||
* @param str | ||
* @return | ||
*/ | ||
public static boolean isNotEmpty(String str) { | ||
return !isEmpty(str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-activemq/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-cassandra/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
3 changes: 3 additions & 0 deletions
3
flink-learning-connectors/flink-learning-connectors-es6/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Flink connector ElasticSearch 6.x | ||
|
||
[http://www.54tianzhisheng.cn/2018/12/30/Flink-ElasticSearch-Sink/](http://www.54tianzhisheng.cn/2018/12/30/Flink-ElasticSearch-Sink/) |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-flume/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-hbase/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-hdfs/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-influxdb/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
3 changes: 3 additions & 0 deletions
3
flink-learning-connectors/flink-learning-connectors-kafka/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Flink connector Kafka | ||
|
||
[http://www.54tianzhisheng.cn/2019/01/06/Flink-Kafka-sink/](http://www.54tianzhisheng.cn/2019/01/06/Flink-Kafka-sink/) |
3 changes: 3 additions & 0 deletions
3
flink-learning-connectors/flink-learning-connectors-mysql/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Flink connector MySQL | ||
|
||
[http://www.54tianzhisheng.cn/2019/01/15/Flink-MySQL-sink/](http://www.54tianzhisheng.cn/2019/01/15/Flink-MySQL-sink/) |
3 changes: 3 additions & 0 deletions
3
flink-learning-connectors/flink-learning-connectors-rabbitmq/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Flink connector RabbitMQ | ||
|
||
[http://www.54tianzhisheng.cn/2019/01/20/Flink-RabbitMQ-sink/](http://www.54tianzhisheng.cn/2019/01/20/Flink-RabbitMQ-sink/) |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-redis/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
1 change: 1 addition & 0 deletions
1
flink-learning-connectors/flink-learning-connectors-rocketmq/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Flink data sink | ||
|
||
[http://www.54tianzhisheng.cn/2018/10/29/flink-sink/](http://www.54tianzhisheng.cn/2018/10/29/flink-sink/) | ||
|
||
[http://www.54tianzhisheng.cn/2018/10/31/flink-create-sink/](http://www.54tianzhisheng.cn/2018/10/31/flink-create-sink/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Flink data source | ||
|
||
[http://www.54tianzhisheng.cn/2018/10/28/flink-sources/](http://www.54tianzhisheng.cn/2018/10/28/flink-sources/) | ||
|
||
[http://www.54tianzhisheng.cn/2018/10/30/flink-create-source/](http://www.54tianzhisheng.cn/2018/10/30/flink-create-source/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Flink 监控、告警、存储 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>flink-learning</artifactId> | ||
<groupId>com.zhisheng.flink</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>flink-learning-state</artifactId> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
模版项目,不做任何代码编写,方便创建新的 module 时复制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>flink-learning</artifactId> | ||
<groupId>com.zhisheng.flink</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>flink-learning-window</artifactId> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters