mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-604 Add overloads that take ZoneId so caller can work with a custom zone id instead of session zone id
This commit is contained in:
@ -168,7 +168,18 @@ public enum DateTimeGroupBy
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String makeSelectedString(Instant time)
|
public String makeSelectedString(Instant time)
|
||||||
{
|
{
|
||||||
ZonedDateTime zoned = time.atZone(ValueUtils.getSessionOrInstanceZoneId());
|
return (makeSelectedString(time, ValueUtils.getSessionOrInstanceZoneId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Make an Instant into a string that will match what came out of the database's
|
||||||
|
** DATE_FORMAT() function
|
||||||
|
*******************************************************************************/
|
||||||
|
public String makeSelectedString(Instant time, ZoneId zoneId)
|
||||||
|
{
|
||||||
|
ZonedDateTime zoned = time.atZone(zoneId);
|
||||||
|
|
||||||
if(this == WEEK)
|
if(this == WEEK)
|
||||||
{
|
{
|
||||||
@ -192,7 +203,17 @@ public enum DateTimeGroupBy
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public String makeHumanString(Instant instant)
|
public String makeHumanString(Instant instant)
|
||||||
{
|
{
|
||||||
ZonedDateTime zoned = instant.atZone(ValueUtils.getSessionOrInstanceZoneId());
|
return (makeHumanString(instant, ValueUtils.getSessionOrInstanceZoneId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Make a string to show to a user
|
||||||
|
*******************************************************************************/
|
||||||
|
public String makeHumanString(Instant instant, ZoneId zoneId)
|
||||||
|
{
|
||||||
|
ZonedDateTime zoned = instant.atZone(zoneId);
|
||||||
if(this.equals(WEEK))
|
if(this.equals(WEEK))
|
||||||
{
|
{
|
||||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M'/'d");
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M'/'d");
|
||||||
@ -225,10 +246,20 @@ public enum DateTimeGroupBy
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@SuppressWarnings("checkstyle:indentation")
|
|
||||||
public Instant roundDown(Instant instant)
|
public Instant roundDown(Instant instant)
|
||||||
{
|
{
|
||||||
ZonedDateTime zoned = instant.atZone(ValueUtils.getSessionOrInstanceZoneId());
|
return roundDown(instant, ValueUtils.getSessionOrInstanceZoneId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@SuppressWarnings("checkstyle:indentation")
|
||||||
|
public Instant roundDown(Instant instant, ZoneId zoneId)
|
||||||
|
{
|
||||||
|
ZonedDateTime zoned = instant.atZone(zoneId);
|
||||||
return switch(this)
|
return switch(this)
|
||||||
{
|
{
|
||||||
case YEAR -> zoned.with(TemporalAdjusters.firstDayOfYear()).truncatedTo(ChronoUnit.DAYS).toInstant();
|
case YEAR -> zoned.with(TemporalAdjusters.firstDayOfYear()).truncatedTo(ChronoUnit.DAYS).toInstant();
|
||||||
@ -253,7 +284,17 @@ public enum DateTimeGroupBy
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public Instant increment(Instant instant)
|
public Instant increment(Instant instant)
|
||||||
{
|
{
|
||||||
ZonedDateTime zoned = instant.atZone(ValueUtils.getSessionOrInstanceZoneId());
|
return (increment(instant, ValueUtils.getSessionOrInstanceZoneId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public Instant increment(Instant instant, ZoneId zoneId)
|
||||||
|
{
|
||||||
|
ZonedDateTime zoned = instant.atZone(zoneId);
|
||||||
return (zoned.plus(noOfChronoUnitsToAdd, chronoUnitToAdd).toInstant());
|
return (zoned.plus(noOfChronoUnitsToAdd, chronoUnitToAdd).toInstant());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user