Skip to content

Commit

Permalink
Remove unused methods and code
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed May 11, 2023
1 parent c201f1e commit 994a09a
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import io.trino.sql.tree.IntervalLiteral.IntervalField;
import org.assertj.core.util.VisibleForTesting;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.DurationFieldType;
import org.joda.time.MutablePeriod;
import org.joda.time.Period;
import org.joda.time.ReadWritablePeriod;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormatterBuilder;
Expand All @@ -48,12 +46,9 @@

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;
import static io.trino.spi.type.DateTimeEncoding.unpackMillisUtc;
import static io.trino.util.DateTimeZoneIndex.getChronology;
import static io.trino.util.DateTimeZoneIndex.getDateTimeZone;
import static io.trino.util.DateTimeZoneIndex.packDateTimeWithZone;
import static io.trino.util.DateTimeZoneIndex.unpackChronology;
import static io.trino.util.DateTimeZoneIndex.unpackDateTimeZone;
import static java.lang.Math.toIntExact;
import static java.lang.String.format;

Expand Down Expand Up @@ -136,7 +131,6 @@ public static String printDate(int days)
return DATE_FORMATTER.print(TimeUnit.DAYS.toMillis(days));
}

private static final DateTimeFormatter TIMESTAMP_WITH_TIME_ZONE_FORMATTER;
private static final DateTimeFormatter TIMESTAMP_WITH_OR_WITHOUT_TIME_ZONE_FORMATTER;

static {
Expand Down Expand Up @@ -165,10 +159,6 @@ public static String printDate(int days)
DateTimeFormat.forPattern("yyyyyy-M-d H:m:s.SSS ZZZ").getParser()};

DateTimePrinter timestampWithTimeZonePrinter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS ZZZ").getPrinter();
TIMESTAMP_WITH_TIME_ZONE_FORMATTER = new DateTimeFormatterBuilder()
.append(timestampWithTimeZonePrinter, timestampWithTimeZoneParser)
.toFormatter()
.withOffsetParsed();

DateTimeParser[] timestampWithOrWithoutTimeZoneParser = Stream.concat(Stream.of(timestampWithoutTimeZoneParser), Stream.of(timestampWithTimeZoneParser))
.toArray(DateTimeParser[]::new);
Expand All @@ -194,15 +184,7 @@ public static long convertToTimestampWithTimeZone(TimeZoneKey timeZoneKey, Strin
return packDateTimeWithZone(dateTime);
}

public static String printTimestampWithTimeZone(long timestampWithTimeZone)
{
ISOChronology chronology = unpackChronology(timestampWithTimeZone);
long millis = unpackMillisUtc(timestampWithTimeZone);
return TIMESTAMP_WITH_TIME_ZONE_FORMATTER.withChronology(chronology).print(millis);
}

private static final DateTimeFormatter TIME_FORMATTER;
private static final DateTimeFormatter TIME_WITH_TIME_ZONE_FORMATTER;

static {
DateTimeParser[] timeWithoutTimeZoneParser = {
Expand All @@ -211,22 +193,6 @@ public static String printTimestampWithTimeZone(long timestampWithTimeZone)
DateTimeFormat.forPattern("H:m:s.SSS").getParser()};
DateTimePrinter timeWithoutTimeZonePrinter = DateTimeFormat.forPattern("HH:mm:ss.SSS").getPrinter();
TIME_FORMATTER = new DateTimeFormatterBuilder().append(timeWithoutTimeZonePrinter, timeWithoutTimeZoneParser).toFormatter().withZoneUTC();

DateTimeParser[] timeWithTimeZoneParser = {
DateTimeFormat.forPattern("H:mZ").getParser(),
DateTimeFormat.forPattern("H:m Z").getParser(),
DateTimeFormat.forPattern("H:m:sZ").getParser(),
DateTimeFormat.forPattern("H:m:s Z").getParser(),
DateTimeFormat.forPattern("H:m:s.SSSZ").getParser(),
DateTimeFormat.forPattern("H:m:s.SSS Z").getParser(),
DateTimeFormat.forPattern("H:mZZZ").getParser(),
DateTimeFormat.forPattern("H:m ZZZ").getParser(),
DateTimeFormat.forPattern("H:m:sZZZ").getParser(),
DateTimeFormat.forPattern("H:m:s ZZZ").getParser(),
DateTimeFormat.forPattern("H:m:s.SSSZZZ").getParser(),
DateTimeFormat.forPattern("H:m:s.SSS ZZZ").getParser()};
DateTimePrinter timeWithTimeZonePrinter = DateTimeFormat.forPattern("HH:mm:ss.SSS ZZZ").getPrinter();
TIME_WITH_TIME_ZONE_FORMATTER = new DateTimeFormatterBuilder().append(timeWithTimeZonePrinter, timeWithTimeZoneParser).toFormatter().withOffsetParsed();
}

/**
Expand All @@ -241,27 +207,6 @@ public static long parseLegacyTime(TimeZoneKey timeZoneKey, String value)
return TIME_FORMATTER.withZone(getDateTimeZone(timeZoneKey)).parseMillis(value);
}

public static String printTimeWithTimeZone(long timeWithTimeZone)
{
DateTimeZone timeZone = unpackDateTimeZone(timeWithTimeZone);
long millis = unpackMillisUtc(timeWithTimeZone);
return TIME_WITH_TIME_ZONE_FORMATTER.withZone(timeZone).print(millis);
}

public static String printTimeWithoutTimeZone(long value)
{
return TIME_FORMATTER.print(value);
}

/**
* @deprecated applicable in legacy timestamp semantics only
*/
@Deprecated
public static String printTimeWithoutTimeZone(TimeZoneKey timeZoneKey, long value)
{
return TIME_FORMATTER.withZone(getDateTimeZone(timeZoneKey)).print(value);
}

private static final int YEAR_FIELD = 0;
private static final int MONTH_FIELD = 1;
private static final int DAY_FIELD = 3;
Expand Down

0 comments on commit 994a09a

Please sign in to comment.