Class DefaultTimeValueConverter

java.lang.Object
sk.iway.iwcm.system.jpa.DefaultTimeValueConverter
All Implemented Interfaces:
javax.persistence.AttributeConverter<Date,Date>

public class DefaultTimeValueConverter extends Object implements javax.persistence.AttributeConverter<Date,Date>
  • Constructor Details

    • DefaultTimeValueConverter

      public DefaultTimeValueConverter()
  • Method Details

    • convertToDatabaseColumn

      public Date convertToDatabaseColumn(Date oldDate)
      Specified by:
      convertToDatabaseColumn in interface javax.persistence.AttributeConverter<Date,Date>
    • convertToEntityAttribute

      public Date convertToEntityAttribute(Date oldDate)
      Specified by:
      convertToEntityAttribute in interface javax.persistence.AttributeConverter<Date,Date>
    • getValidTimeValue

      public static Date getValidTimeValue(Date oldDate)
      If input oldValue is null, it will be returned default Date 01-01-2000 00:00:00. If input oldValue isnt null, value of hours/minutes/seconds will remain, but value of day/month/year will be set on default value 01-01-2000 (rest is same).
      Parameters:
      oldDate - value of date we need to correct
      Returns:
      valid date for TIME_HM and TIME_HMS DataTableColumnTypes
    • getValidTimeValue

      public static Date getValidTimeValue(int hours, int minutes)
      Create valid date where day/month/year is set to 01.01.2000, seconds are set at 0 and hours/minutes are set using input values.
      Parameters:
      hours - number of hours we want to set into date
      minutes - number of minutes we want to set into date
      Returns:
      valid date for TIME_HM and TIME_HMS DataTableColumnTypes
    • getValidTimeValue

      public static Date getValidTimeValue(int hours, int minutes, int seconds)
      Create valid date where day/month/year is set to 01.01.2000 and seconds/hours/minutes are set using input values.
      Parameters:
      hours - number of hours we want to set into date
      minutes - number of minutes we want to set into date
      seconds - number of seconds we want to set into date
      Returns:
      valid date for TIME_HM and TIME_HMS DataTableColumnTypes
    • combineDateWithTime

      public static Date combineDateWithTime(Date date, Date time)
      Combine yyyy-mm-dd from input "date" with hh:mm:ss from input "time" and return new date. Milliseconds are default set to 0. If any of iput values is null, null will be returned.
      Parameters:
      date - date value representing yyyy-mm-dd in new date
      time - date value representing hh:mm:ss in new date
      Returns:
      date value represent date time combination
    • combineDateWithTime

      public static Date combineDateWithTime(long date, long time)