MisterNowhere
MisterNowhere

Reputation: 615

Date and time in different languages

I want my app to show the German version if the phone language is German, and the English version if the phone language is English.

There is this Predefined Formats, but for the German version I don't like it.

How can I handle this?

private fun getTime(currentTime:Long): String{
    val sdf = SimpleDateFormat("HH:mm")
    val calendar = Calendar.getInstance()
    calendar.timeInMillis = currentTime
    val str = sdf.format(calendar.time)
    return str
}

private fun getDate(currentTime:Long):String{
    val myDate = Date()
    val actualDate = myDate.time.plus(currentTime)
    val myString = DateFormat.getDateInstance().format(actualDate)
    return myString
}

Upvotes: 0

Views: 357

Answers (1)

Minas Mina
Minas Mina

Reputation: 2107

Try using this constructor:

public SimpleDateFormat(String pattern, Locale locale)

Reference

Upvotes: 1

Related Questions