001package de.bytefish.pgbulkinsert.pgsql.model.interval; 002 003import java.util.concurrent.TimeUnit; 004 005public class Interval { 006 007 private final int months; 008 private final int days; 009 private final long timeOfDay; 010 011 public Interval(int months, int days, long timeOfDay) { 012 this.months = months; 013 this.days = days; 014 this.timeOfDay = timeOfDay; 015 } 016 017 public Interval(int months, int days, int hours, int minutes, int wholeSeconds, long microSeconds) { 018 this.months = months; 019 this.days = days; 020 this.timeOfDay = calcTimeOfDay(hours, minutes, wholeSeconds, microSeconds); 021 } 022 023 public int getMonths() { 024 return months; 025 } 026 027 public int getDays() { 028 return days; 029 } 030 031 public long getTimeOfDay() { 032 return timeOfDay; 033 } 034 035 private long calcTimeOfDay(int hours, int minutes, int wholeSeconds, long microSeconds) { 036 return TimeUnit.HOURS.toMicros(hours) 037 + TimeUnit.MINUTES.toMicros(minutes) 038 + TimeUnit.SECONDS.toMicros(wholeSeconds) 039 + microSeconds; 040 } 041}