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:
Error occurred on line: (as indicated in above code with <<<<<<<<<<<<)
java.lang.RuntimeException: Method: setTimeZoneInternal not found in: anywheresoftware.b4a.keywords.DateTime
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at treetops.app.customer.aws_s3._gmtstring(aws_s3.java:890)
at treetops.app.customer.aws_s3._fullheadermap(aws_s3.java:192)
at treetops.app.customer.main$ResumableSub_Activity_Resume.resume(main.java:2196)
at treetops.app.customer.main._activity_resume(main.java:639)
at treetops.app.customer.main._event_http_responseerror(main.java:5931)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

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: 287
Upvote 0
Top