1
0

[HUDI-3547] Introduce MaxwellSourcePostProcessor to extract data from Maxwell json string (#4987)

* [HUDI-3547] Introduce MaxwellSourcePostProcessor to extract data from Maxwell json string

* add ut

* Address comment
This commit is contained in:
wangxianghu
2022-03-15 15:06:30 +04:00
committed by GitHub
parent d40adfa2d7
commit 3b59b76952
4 changed files with 381 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ package org.apache.hudi.common.util;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
@@ -126,6 +129,20 @@ public class DateTimeUtils {
return labelToUnit;
}
/**
* Convert UNIX_TIMESTAMP to string in given format.
*
* @param unixTimestamp UNIX_TIMESTAMP
* @param timeFormat string time format
*/
public static String formatUnixTimestamp(long unixTimestamp, String timeFormat) {
ValidationUtils.checkArgument(!StringUtils.isNullOrEmpty(timeFormat));
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(timeFormat);
return LocalDateTime
.ofInstant(Instant.ofEpochSecond(unixTimestamp), ZoneId.systemDefault())
.format(dtf);
}
/**
* Enum which defines time unit, mostly used to parse value from configuration file.
*/