DateUtils class

Name: 日期时间工具类 Created by Fitem on 2023/7/17

Constructors

DateUtils()

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

diff(DateTime start, DateTime end) int
计算两个时间的时间差 start 开始时间 end 结束时间 返回值:毫秒数 若为负值,则表示 endstart 之前
diffRangeLevel(DateTime start, DateTime end) int
计算两个时间的差值范围等级 start 开始时间 end 结束时间 返回值:0 - 6 对应 1分钟内、1小时内、1天内、1周内、1月内、1年内、1年以上
diffRangeName(DateTime start, DateTime end, [List<String> timeRangeList = timeRangeList]) String
相差时间范围说明 start 开始时间 end 结束时间 timeRangeList 相差时间名称列表 默认为 timeRangeList
formatDate(DateTime timestamp, [String format = dateFormat]) String
日期格式化 timestamp 时间戳 format 格式化字符串 默认为 dateFormat 默认返回:2021-07-17
formatDateTime(DateTime timestamp, [String format = dateTimeFormat]) String
日期时间格式化 timestamp 时间戳 format 格式化字符串 默认为 dateTimeFormat 默认返回:2021-07-17 15:30:00
formatHHmm(DateTime timestamp, [String format = timeFormat2]) String
时分格式化 timestamp 时间戳 format 格式化字符串 默认为 timeFormat2 默认返回:15:30
formatTime(DateTime timestamp, [String format = timeFormat]) String
时间格式化 timestamp 时间戳 format 格式化字符串 默认为 timeFormat 默认返回:15:30:00
getWeekIndex(DateTime timestamp) int
获取星期几 time 时间字符串 从周一开始,周日为6
getWeekName(DateTime timestamp, [List<String> weekList = weekList]) String
获取星期名称 time 时间字符串 weekList 星期名称列表 默认为 weekList
parseDateTime(String time, [String format = dateTimeFormat, bool utc = false]) DateTime
解析日期时间 time 时间字符串 format 格式化字符串 默认为 dateTimeFormat utc 是否使用utc时间 默认为 false

Constants

dateFormat → const String
dateFormat2 → const String
dateFormat3 → const String
dateTimeFormat → const String
日期格式化
oneDay → const int
oneHour → const int
oneMinute → const int
oneMonth → const int
oneSecond → const int
时间计算
oneWeek → const int
oneYear → const int
timeFormat → const String
timeFormat2 → const String
timeRangeList → const List<String>
相差时间名称列表
weekList → const List<String>
星期名称列表