DateUtils class
日期时间工具类
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addMonths(
DateTime date, int months) → DateTime - Returns the DateTime resulting from adding the given number of months to this DateTime.
-
copyWith(
DateTime date, {int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → DateTime -
Creates a copy of
date
but with the given fields replaced with the new values. -
firstDayOfFirstWeek(
int year, {int? firstWeekday}) → DateTime -
Returns start of the first day of the first week in
year
. -
firstDayOfMonth(
DateTime date) → DateTime -
Returns DateTime that represents a beginning
of the first day of the month containing
date
. -
firstDayOfNextMonth(
DateTime dateTime) → DateTime - Returns DateTime that represents a beginning of the first day of the next month.
-
firstDayOfNextWeek(
DateTime dateTime, {int? firstWeekday}) → DateTime -
Returns start of the first day of the next week for specified
dateTime
. -
firstDayOfNextYear(
DateTime dateTime) → DateTime - Returns DateTime that represents a beginning of the first day of the next year.
-
firstDayOfWeek(
DateTime dateTime, {int? firstWeekday}) → DateTime -
Returns start of the first day of the week for specified
dateTime
. -
firstDayOfYear(
DateTime dateTime) → DateTime -
Returns DateTime that represents a beginning
of the first day of the year containing
date
. -
formatDate(
DateTime? dateTime, {String? format}) → String - format date by DateTime. format 转换格式(已提供常用格式 DateFormats,可以自定义格式:'yyyy/MM/dd HH:mm:ss')
-
formatDateMilliseconds(
int ms, {bool isUtc = false, String format = ""}) → String - format date by milliseconds. 格式化日期毫秒时间
-
formatDateString(
String dateStr, {bool isUtc = false, String format = ""}) → String - format date by date str. 格式化日期字符串
-
generateWithDayStep(
DateTime start, DateTime end) → Iterable< DateTime> -
Returns an iterable of
DateTime
with 1 day step in given range. -
getDateMsByTimeString(
String dateStr, {bool? isUtc}) → int? - get DateMilliseconds By DateStr. 将字符串时间转化为毫秒值
-
getDateTime(
String dateStr, {bool? isUtc}) → DateTime? - get DateTime By DateStr. 将字符串时间转化为DateTime
-
getDateTimeByMs(
int ms, {bool isUtc = false}) → DateTime - get DateTime By Milliseconds. 将毫秒时间转化为DateTime
-
getDayNumberInWeek(
DateTime date, {int? firstWeekday}) → int - Returns number of the day in week (starting with 1).
-
getDayNumberInYear(
DateTime date) → int - Returns number of the day in year.
-
getDayOfYear(
DateTime dateTime) → int - get day of year. 在今年的第几天.
-
getDayOfYearByMilliseconds(
int ms, {bool isUtc = false}) → int - get day of year. 在今年的第几天.
-
getDaysDifference(
DateTime a, DateTime b) → int - Returns count of days between two dates.
-
getDaysInMonth(
int year, int monthNum) → int -
Returns number of days in the
month
of theyear
. -
getDaysInYear(
int year) → int - Returns the number of days in a given year.
-
getLastWeekNumber(
int year, {int? firstWeekday}) → int -
Returns number of the last week in
year
. -
getNowDateMs(
) → int - get Now Date Milliseconds. 获取当前毫秒值
-
getNowDateString(
) → String - get Now Date Str.(yyyy-MM-dd HH:mm:ss) 获取现在日期字符串,默认是:yyyy-MM-dd HH:mm:ss
-
getNowDateTime(
) → DateTime - get Now Date Time. 获取当前日期返回DateTime
-
getNowDateTimeFormat(
String outFormat) → String - 获取当前日期,返回指定格式
-
getNowUtcDateTime(
) → DateTime - 获取当前日期返回DateTime(utc)
-
getUtcDateTimeFormat(
String outFormat) → String - 获取当前日期,返回指定格式
-
getWeekday(
DateTime dateTime, {String languageCode = 'en', bool short = false}) → String - get WeekDay. 获取dateTime是星期几
-
getWeekdayByMilliseconds(
int milliseconds, {bool isUtc = false, String languageCode = 'en', bool short = false}) → String - get WeekDay By Milliseconds. 获取毫秒值对应是星期几
-
getWeekNumber(
DateTime date, {int? firstWeekday}) → int - Returns week number in year.
-
getYesterday(
) → DateTime - 获取昨天日期返回DateTime
-
isCurrentDate(
DateTime date) → bool - Проверяет является ли заданная дата текущей.
-
isFirstDayOfMonth(
DateTime day) → bool -
Checks if
day
is in the first day of a month. -
isFirstDayOfWeek(
DateTime day, {int? firstWeekday}) → bool -
Checks if
day
is in the first day of a week. -
isLastDayOfMonth(
DateTime day) → bool -
Checks if
day
is in the last day of a month. -
isLastDayOfWeek(
DateTime day, {int? firstWeekday}) → bool -
Checks if
day
is in the last day of a week. -
isLeapYear(
DateTime dateTime) → bool - Return whether it is leap year. 是否是闰年
-
isLeapYearByMilliseconds(
int milliseconds) → bool - Return whether it is leap year. 是否是闰年
-
isLeapYearByYear(
int year) → bool - Return whether it is leap year. 是否是闰年
-
isSameDay(
DateTime a, DateTime b) → bool - 判断a和b两个时间是否是同一天
-
isToday(
int milliseconds, {bool isUtc = false, int? locMs}) → bool - is today. 根据时间戳判断是否是今天
-
isWeek(
int ms, {bool isUtc = false, int? locMs}) → bool - is Week. 根据时间戳判断是否是本周
-
isWeekInYear(
DateTime date, int year, int firstWeekday) → bool -
Checks if week, that contains
date
is inyear
. -
isYesterday(
DateTime dateTime, DateTime locDateTime) → bool - is yesterday by dateTime. 根据时间判断是否是昨天
-
isYesterdayByMilliseconds(
int ms, int locMs) → bool - is yesterday by millis. 是否是昨天.
-
lastDayOfMonth(
DateTime dateTime) → DateTime -
Returns DateTime that represents a beginning
of the last day of the month containing
date
. -
lastDayOfWeek(
DateTime dateTime, {int? firstWeekday}) → DateTime -
Returns start of the last day of the week for specified
dateTime
. -
lastDayOfYear(
DateTime dateTime) → DateTime -
Returns DateTime that represents a beginning
of the last day of the year containing
date
. -
nextDay(
DateTime d) → DateTime - Returns same time in the next day.
-
nextMonth(
DateTime date) → int - Returns a number of the next month.
-
nextYear(
DateTime d) → DateTime - Returns same date in the next year.
-
previousDay(
DateTime d) → DateTime - Returns same time in the previous day.
-
previousYear(
DateTime d) → DateTime - Returns same date in the previous year.
-
setTime(
DateTime date, int hours, int minutes, [int seconds = 0, int milliseconds = 0, int microseconds = 0]) → DateTime -
Creates a copy of
date
but with time replaced with the new values. -
startOfDay(
DateTime dateTime) → DateTime - Returns DateTime for the beginning of the day (00:00:00).
-
startOfNextDay(
DateTime dateTime) → DateTime - Returns DateTime for the beginning of the next day (00:00:00).
-
startOfToday(
) → DateTime - Returns DateTime for the beginning of today (00:00:00).
-
yearIsEqual(
DateTime dateTime, DateTime locDateTime) → bool - year is equal. 是否同年.
-
yearIsEqualByMilliseconds(
int ms, int locMs) → bool - year is equal. 是否同年.