[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:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user