DateUtils

object DateUtils

Date utils.

Types

Link copied to clipboard
annotation class GmtFormatString

The ID for a TimeZone.

Properties

Link copied to clipboard
const val FORMAT_HH_MM: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val FORMAT_MM_SS: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val FORMAT_YYYY: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val GMT_PLUS_ONE: String
Link copied to clipboard
Link copied to clipboard
const val GMT_PLUS_SIX: String
Link copied to clipboard
const val GMT_PLUS_TEN: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val GMT_PLUS_TWO: String
Link copied to clipboard
Link copied to clipboard
const val TAG: String

Functions

Link copied to clipboard
private fun datetimeFormat(dateFormat: String): SimpleDateFormat

Constructs a SimpleDateFormat using the dateFormat and the Locale.getDefault.

Link copied to clipboard
fun dateTimeFromGMT(utcTime: String, dateFormat: String): String

Get current local time string by parsing the utcTime in dateFormat format.

Link copied to clipboard
fun datetimeFromString(timeString: String, timeStringFormat: String, callback: Date? = null): Date

Get date object by parsing timeString in timeStringFormat format.

Link copied to clipboard
fun dateTimeToGMT(gmtFormat: String = getCurrentTimeZone(), dateFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Formats a Date of System.currentTimeMillis into a date/time string by parsing dateFormat and gmtFormat.

Link copied to clipboard
fun datetimeToString(date: Date = Date(), dateFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Formats a Date into a date/time string by parsing dateFormat.

Link copied to clipboard
fun datetimeToTimeMillis(time: String, timeFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): Long?

Convert the time in the format of timeFormat to milliseconds. Returns null if time parsing exception occurs

Link copied to clipboard
fun getCurrentTime(dateFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Get current time.

Link copied to clipboard
fun getCurrentTimeZone(style: Int = TimeZone.SHORT): String

Get the default time zone for this host in string.

Link copied to clipboard
fun getDayBeforeOrAfterCurrentTime(dateFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS, beforeOrAfter: Int): String

Get the days before or after the current time.

Link copied to clipboard
fun getWeekEndTime(calendar: Calendar = Calendar.getInstance(), yearFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Get the end timestamp of the week. SUNDAY is the first day of the week.

Link copied to clipboard
fun getWeekStartTime(calendar: Calendar = Calendar.getInstance(), yearFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Get the start timestamp of the week. SUNDAY is the first day of the week.

Link copied to clipboard
fun weekEndTime(yearFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Get the end timestamp of the week. Monday is the first day of the week.

Link copied to clipboard
fun weekStartTime(yearFormat: String = FORMAT_YYYY_MM_DD_HH_MM_SS): String

Get the start timestamp of the week. Monday is the first day of the week.