iOS Question Decimal seperator according to region and language


Licensed User
Public Sub AusgabeWert(language As String, region As String, einheit As String ,number As Double) As String
    Dim jo As JavaObject
    jo = jo.InitializeNewInstance("java.util.Locale.Builder", Null)
    Dim locale As JavaObject = jo.RunMethodJO("setLanguage", Array As Object(language)).RunMethodJO("setRegion", Array As Object(region)).RunMethod("build", Null)
    Dim numberFormatter As JavaObject = jo.InitializeStatic("java.text.NumberFormat").RunMethod("getNumberInstance", Array As Object(locale))
    Dim retVal As String = numberFormatter.RunMethod("format", Array As Object(number))
    Return retVal
end sub

Have to transfer this B4A code...
How can i do that in IOS ?
Thanks for help...


Licensed User
How can i do that in IOS ?
If the user types in similar information, then you could take your cue from that eg before converting user input number from string to numeric, check to see if they've used a dot or a comma, and set the decimal separator character accordingly.

I've done similar stuff with units and date/time formats, eg if user enters "27cm" then changes to metric, or if enters "11in" (or "11 inch" or "11 inches") then changes to imperial.

Also super-popular with users was ability to type dates such as "yesterday", "today", "tomorrow", "next monday", "last tuesday", etc although there was occasional disagreement about whether eg if today is Tuesday, then is next Wednesday the following day, or the Wednesday of next week? 🤔
Last edited:
Upvote 0


Staff member
Licensed User
Dim formatter As B4XFormatter
formatter.GetDefaultFormat.DecimalPoint = GetDecimalSeparator

Sub GetDecimalSeparator As String
    Dim locale As NativeObject
    Return locale.Initialize("NSLocale").RunMethod("currentLocale", Null).GetField("decimalSeparator").AsString
End Sub
Upvote 0