ANDROIDSTUDYCHANNEL Telegram 3319
fun covertTimeToText(dataDate: String): String? {
var convertTime: String? = null
try {
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
val pasTime: Date = dateFormat.parse(dataDate)
val nowTime = Date()
val dateDiff = floor((nowTime.time.toDouble() - pasTime.time.toDouble()) / 1000).toInt()
when {
dateDiff < 60 -> {
convertTime = "لحظاتی پیش"
}
dateDiff < 150 -> {
convertTime = "دقایقی پیش"
}
dateDiff < 300 -> {
convertTime = "۵ دقیقه پیش"
}
dateDiff < 600 -> {
convertTime = "۱۰ دقیقه پیش"
}
dateDiff < 900 -> {
convertTime = "یک ربع پیش"
}
dateDiff < 1800 -> {
convertTime = "نیم ساعت پیش"
}
dateDiff in 1800..3599 -> {
convertTime = "۴۵ دقیقه پیش"
}
dateDiff in 3600..86400 -> {
val interval = (dateDiff / 3600)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " ساعت پیش "
}
dateDiff in 86400..2591999 -> {
val interval = (dateDiff / 86400)
when (interval) {
1 -> {
convertTime = "دیروز"
}
in 2..6 -> {
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " روز پیش "
}
7 -> {
convertTime = "یک هفته پیش"
}14 -> {
convertTime = "دو هفته پیش"
}21 -> {
convertTime = "سه هفته پیش"
}28 -> {
convertTime = "چهار هفته پیش"
}
else -> {
convertTime =
Farsi_Number_Change.Changefarsi(interval.toString()) + " روز پیش "
}
}

}
dateDiff in 2592000..31535999 -> {
val interval = (dateDiff / 2592000)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " ماه پیش "
}

dateDiff in 31536000..915360000 -> {
val interval = (dateDiff / 31536000)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " سال پیش "
}

}

} catch (e: Exception) {

}
return convertTime
}
👍1



tgoop.com/AndroidStudyChannel/3319
Create:
Last Update:

fun covertTimeToText(dataDate: String): String? {
var convertTime: String? = null
try {
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
val pasTime: Date = dateFormat.parse(dataDate)
val nowTime = Date()
val dateDiff = floor((nowTime.time.toDouble() - pasTime.time.toDouble()) / 1000).toInt()
when {
dateDiff < 60 -> {
convertTime = "لحظاتی پیش"
}
dateDiff < 150 -> {
convertTime = "دقایقی پیش"
}
dateDiff < 300 -> {
convertTime = "۵ دقیقه پیش"
}
dateDiff < 600 -> {
convertTime = "۱۰ دقیقه پیش"
}
dateDiff < 900 -> {
convertTime = "یک ربع پیش"
}
dateDiff < 1800 -> {
convertTime = "نیم ساعت پیش"
}
dateDiff in 1800..3599 -> {
convertTime = "۴۵ دقیقه پیش"
}
dateDiff in 3600..86400 -> {
val interval = (dateDiff / 3600)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " ساعت پیش "
}
dateDiff in 86400..2591999 -> {
val interval = (dateDiff / 86400)
when (interval) {
1 -> {
convertTime = "دیروز"
}
in 2..6 -> {
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " روز پیش "
}
7 -> {
convertTime = "یک هفته پیش"
}14 -> {
convertTime = "دو هفته پیش"
}21 -> {
convertTime = "سه هفته پیش"
}28 -> {
convertTime = "چهار هفته پیش"
}
else -> {
convertTime =
Farsi_Number_Change.Changefarsi(interval.toString()) + " روز پیش "
}
}

}
dateDiff in 2592000..31535999 -> {
val interval = (dateDiff / 2592000)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " ماه پیش "
}

dateDiff in 31536000..915360000 -> {
val interval = (dateDiff / 31536000)
convertTime = Farsi_Number_Change.Changefarsi(interval.toString()) + " سال پیش "
}

}

} catch (e: Exception) {

}
return convertTime
}

BY 🔴 ANDROID PROGRAMMING CHANNEL


Share with your friend now:
tgoop.com/AndroidStudyChannel/3319

View MORE
Open in Telegram


Telegram News

Date: |

Telegram Channels requirements & features The initiatives announced by Perekopsky include monitoring the content in groups. According to the executive, posts identified as lacking context or as containing false information will be flagged as a potential source of disinformation. The content is then forwarded to Telegram's fact-checking channels for analysis and subsequent publication of verified information. best-secure-messaging-apps-shutterstock-1892950018.jpg More>> Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October.
from us


Telegram 🔴 ANDROID PROGRAMMING CHANNEL
FROM American