Android Question [SOLVED] Problem with changing time zones

JackKirk

Well-Known Member
Licensed User
Longtime User
Hi,
I'm using the following code to change time zones from whatever the original is to GMT then back again:
B4X:
Private Sub GMTstring(DateFormatString As String) As String
 
    Private wrk_str As String
    Private wrk_tz_orig As String
 
    Private wrk_jo As JavaObject
    wrk_jo.InitializeStatic("anywheresoftware.b4a.keywords.DateTime")
    Dim wrk_tz As JavaObject

    'Get ID of current time zone
    wrk_tz.InitializeStatic("java.util.TimeZone")
    wrk_tz = wrk_tz.RunMethod("getDefault", Null)
    wrk_tz_orig = wrk_tz.RunMethod("getID", Null)

    'Çhange current time zone to GMT
    wrk_tz.InitializeStatic("java.util.TimeZone")
    wrk_tz = wrk_tz.RunMethod("getTimeZone", Array("GMT"))
    wrk_jo.RunMethod("setTimeZoneInternal", Array(wrk_tz))         '<<<<<<<<<<<<<<< Error occurs here

    'Get current GMT in requested format
    DateTime.DateFormat = DateFormatString
    wrk_str = DateTime.Date(AWS_S3_GMT)

    'Restore original time zone
    wrk_tz.InitializeStatic("java.util.TimeZone")
    wrk_tz = wrk_tz.RunMethod("getTimeZone", Array(wrk_tz_orig))
    wrk_jo.RunMethod("setTimeZoneInternal", Array(wrk_tz))
 
    Return wrk_str

End Sub
This work fine in B4J but fails in B4A with:

Can anyone provide any clues?

Thanks...

PS B4A is at 10.2, B4J is at 8.50
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
Sounds like a mistake. Can't say more without more information.
Erel,

Attached is a B4A example that fails as I have stated.

Thanks...
 

Attachments

  • GMTbug.zip
    9.2 KB · Views: 199
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…