Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zhisheng17 committed Apr 8, 2019
1 parent b09d1ef commit fcf1cfd
Show file tree
Hide file tree
Showing 27 changed files with 260 additions and 0 deletions.
1 change: 1 addition & 0 deletions flink-learning-cep/README.md
@@ -0,0 +1 @@
## Flink CEP
1 change: 1 addition & 0 deletions flink-learning-common/README.md
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
5 changes: 5 additions & 0 deletions flink-learning-common/pom.xml
Expand Up @@ -39,6 +39,11 @@
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
</dependencies>

<build>
Expand Down
@@ -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);
}

}
@@ -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);
}
}
1 change: 1 addition & 0 deletions flink-learning-connectors/README.md
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -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/)
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -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/)
@@ -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/)
@@ -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/)
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
5 changes: 5 additions & 0 deletions flink-learning-data-sinks/README.md
@@ -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/)
5 changes: 5 additions & 0 deletions flink-learning-data-sources/README.md
@@ -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/)
1 change: 1 addition & 0 deletions flink-learning-monitor/README.md
@@ -0,0 +1 @@
## Flink 监控、告警、存储
1 change: 1 addition & 0 deletions flink-learning-sql/README.md
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
1 change: 1 addition & 0 deletions flink-learning-state/README.md
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
15 changes: 15 additions & 0 deletions flink-learning-state/pom.xml
@@ -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>
1 change: 1 addition & 0 deletions flink-learning-window/README.md
@@ -0,0 +1 @@
模版项目,不做任何代码编写,方便创建新的 module 时复制
15 changes: 15 additions & 0 deletions flink-learning-window/pom.xml
@@ -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>
2 changes: 2 additions & 0 deletions pom.xml
Expand Up @@ -18,6 +18,8 @@
<module>flink-learning-sql</module>
<module>flink-learning-examples</module>
<module>flink-learning-monitor</module>
<module>flink-learning-window</module>
<module>flink-learning-state</module>
</modules>

<properties>
Expand Down

0 comments on commit fcf1cfd

Please sign in to comment.