B4J Question Localization problem with month and day names

tanush62

Member
In debug mode I have no problem. My day and month names in datetime are in my language, but in release mode and after compiling with B4jpackager11 they are in english.

How to resolve this?
I'm trying to use this code:
B4X:
Sub ConvertDate(DateTimeString As String, DateTimeFormat As String, NewDateTimeFormat As String,Language As String,Country As String) As String    'ignore
    Dim JOLocale As JavaObject
    Dim JODTConvertTo As JavaObject
    Dim JODTConvertFrom As JavaObject
    Dim JODate As JavaObject
  
    JOLocale.InitializeNewInstance("java.util.Locale",Array As Object(Language,Country))
    JODTConvertTo.InitializeNewInstance("java.text.SimpleDateFormat",Array As Object(NewDateTimeFormat,JOLocale))
    JODTConvertFrom.InitializeNewInstance("java.text.SimpleDateFormat",Array As Object(DateTimeFormat))
    JODate  = JODTConvertFrom.RunMethod("parse",Array As Object(DateTimeString))
    Return JODTConvertTo.RunMethod("format",Array As Object(JODate))
End Sub
..but I have a problem when I try to use Serbian language with latin letters (they are using both cyrillic and latin). With sr & RS for as parameters for language and country i get cyrillic letters. How to get sr-latn-RS?
 

tanush62

Member
First step is to remove this code.

What is the output of:
B4X:
Log(DateUtils.GetMonthName(DateTime.Now))
?
In debug mode:
мај (cyrillic for may in macedonian)
After compiling I get it in english. I use Java 11

Which code to remove?
"Sub ConvertDate" ? I need that if computer is not set to regional locale.
I can get all languages (months and days) except few which uses two or more cripts (like sebian latin). In that sub I can only put two letters code for language and country.


P.S.The code by Mr. @keirS I find here: https://www.b4x.com/android/forum/threads/solved-names-of-the-week-days-locale.91735/post-579690
 
Last edited:
Upvote 0
Top