Skip to content

DateTimeUtils

Shanti Ranjan Das edited this page Dec 3, 2020 · 3 revisions
  • getTimeFromMillis(date_time_millisecond: String, dateFormat: String): String
    Method to get date and time, provide your milliseconds in String and dateformat like HH:MM:SS or more, You can use DateUtils constant object for predefined format or your can provide your own format.

  • getDifferenceHHmmSS(startTime: Long?, endTime: Long?, formatSpecifier: String): String
    Get minutes from start and end time. Pass your own format specifier like (:,-,/) so that it can be like HH:MM:SS,HH-MM-SS.,etc

  • convertDate(date: String, defaultFormat: String, formatWanted: String): String
    Method to convert one date format to another format.
    date : date string which you want to convert
    defaultFormat : default format in which your date is present(like YYYY-MM-DD)
    formatWanted : the format in which you wanted to parse it(like DD/MM/YYYY)

  • getDifferenceInMin(startTime: Long?, endTime: Long?): Int?
    Method to get minutes from start and end time, in which startTime and endTime are milliseconds.

  • getDifference(startTime: Long, endTime: Long, rTimeConst: String): Long
    method to get minutes from start and end time.
    @param startTime provide start time in millis endTime : provide end time in millis rTimeConst pass RTimeConstant value, like if you want return type as hour then pass TimeConstant.HOUR, if min then TimeConst.MIN and so on.You can only use TimeConst.DAY,HOUR or MIN, don't use other values, in other cases it will return min only. It will return hours as Long and minutes added.

  • getDateTimeFromMillis(millis: Long, dateFormat: String): String
    Method to get Date time from millis, You can use System.currentTimeMillis().

  • getCurrentTimeStampWithSecRoundOff(millis: Long): String
    Current system time in millis in String form with seconds to 00 in 24 hour format.

  • getCurTimeInMillis(): Long
    Return current time in millis.

  • get24HourCurTime(): String
    Return current time 24 hour format.

  • get12HourCurTime(): String
    Return current time in 12 hour format.

  • getCurDate(format: String): String
    Return current date in your given String format.

  • addRemMinToHHMM(currentHHMM: String, minutes_to_add: Int?): String
    Method to provide HH:MM:SS after adding miutes to current HH:MM

  • getDaysFromMillis(millis: Long)
    Return days only from milliseconds.

  • getDaysFromMinutes(min: Long)
    Return days from minutes.

  • getDaysFromHours(hours: Long)
    Return days from hours.

  • getDaysFromSeconds(seconds: Long)
    Return days from second.

  • getHourFromMillis(millis: Long)
    Return hour from milliseconds.

  • getHourFromSeconds(seconds: Long)
    Return hour from seconds.

  • getHourFromMinutes(min: Long)
    Return hour from minutes.

  • getHourFromDays(days: Long) Return hour from days.

  • getMinFromMillis(millis: Long)
    Return minute from milliseconds.

  • getMinFromSeconds(seconds: Long)
    Return minute from seconds.

  • getMinFromHours(hours: Long)
    Return min from hours.

  • getMinFromDays(days: Long)
    Return minute from days.

  • getSecFromMillis(millis: Long)
    Return seconds from milliseconds.

  • getSecFromMinute(min: Long)
    Return seconds from minute.

  • getSecFromHours(hours: Long)
    Return seconds from hours.

  • getSecFromDays(days: Long)
    Return seconds from days.

  • getMillisFromSecond(seconds: Long)
    Return milliseconds from seconds.

  • getMillisFromMinute(min: Long)
    Return milliseconds from minute.

  • getMillisFromHours(hours: Long)
    Return milliseconds from hours.

  • getMillisFromDays(days: Long)
    Return milliseconds from days.

  • getFormattedTime(format: String, millis: Int): String
    Method to get String date from millis.

  • convert24HoursTimeTo12HoursTime(hhmm: String): String
    Method to convert 12 hours time hh:mm to 24 hours time.

  • getMillisFromHHMMSS(hhmmss: String): Long
    Method to get milliseconds from HHMMSS.

  • getUtcDateTime(dateAndTime: String?): String
    Method to get get utc time from provided date and time provided date and time must be in "yyyy/MM/dd HH:mm:ss" format i.e., "2020/20/03 04:50:00".

  • utcToDateTime(utcDate: String?, sdf: SimpleDateFormat): Date
    Converts UTC time formatted as ISO to device local time.

Clone this wiki locally