Skip to content

Commit

Permalink
EPMRPP-88461 Switch to LocalDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
grabsefx committed Feb 5, 2024
1 parent 406efa0 commit d266d18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/com/epam/ta/reportportal/commons/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ public class EntityUtils {
.toLocalDateTime())
.orElse(null);


/**
* This operator performs time zone conversion for date and time.
* Specifically, it converts input dates from UTC timezone to the system default timezone.
* Usage:
* LocalDateTime originalDate = ...;
* LocalDateTime localDate = FROM_UTC_TO_LOCAL_DATE_TIME.apply(originalDate);
*
*/
public static final UnaryOperator<LocalDateTime> FROM_UTC_TO_LOCAL_DATE_TIME =
localDateTime -> ofNullable(localDateTime)
.map(date -> date.atZone(ZoneOffset.UTC)
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime())
.orElse(null);

public static final Function<LocalDateTime, Date> TO_DATE = localDateTime -> ofNullable(
localDateTime).map(l -> Date.from(l.atZone(
ZoneOffset.UTC).toInstant())).orElse(null);
Expand Down

0 comments on commit d266d18

Please sign in to comment.