package com.sw.inbound.utils import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow import java.text.SimpleDateFormat import java.util.Date import java.util.Locale /** * 时间格式化工具类 */ object DateTimeUtils { /** * 获取完整中文日期格式(示例:2025年6月11日 星期三) */ fun getChineseDateString(date: Date = Date()): String { return SimpleDateFormat("yyyy年M月d日 EEEE", Locale.CHINA).format(date) } /** * 获取带时间的完整中文格式(示例:2025年6月11日 星期三 14:30) */ fun getChineseDateTimeString(date: Date = Date()): String { return SimpleDateFormat("yyyy年M月d日 EEEE HH:mm:ss", Locale.CHINA).format(date) } /** * 实时时间流(每秒更新) */ fun realTimeChineseDateFlow() = flow { while (true) { emit(getChineseDateString()) delay(1000) } } }