Android Question Trying to compare current time using TimeParse

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Can you tell me where I made mistakes?

I'm trying to see if the current time is equal or greater than a value stored in a label view text property.

Thanks.

B4X:
Sub TheTimeIsInTheSilentPeriods() As Boolean
   
    Dim blnReturnValue As Boolean = False
    Dim lngTicksNow As Long = DateTime.Now
    Dim lngTicksStartTime As Long = DateTime.TimeParse(strSilentPeriod1Start)   

    If lngTicksNow => lngTicksStartTime Then
        ToastMessageShow("The time is part of the silent period.", False)
    End If
   
    Return blnReturnValue
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
What is the format of strSilentPeriod1Start?

Maybe you need to use DateTime.DateTimeParse.

You could also use DateUtils.PeriodBetween.

[I would pass strSilentPeriod1Start as parameter instead of use a global variable]
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi LucaMs,

Thanks for the reply.

strSilentPeriod1Start looks like this:
14:53

Could you show a code sample? My code gives a Java error when I try to compile it. Looks like the error is at the If statement.

When the code is working, I will be using strSilentPeriod1Start, strSilentPeriod1End, strSilentPeriod2Start, strSilentPeriod2End. There will be a total of 5 starting and ending silent periods to be tested against the current time.

Thanks.
 
Last edited:
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Here is a screen shot of the Java error.
 

Attachments

  • Screen Shot 2015-08-06 at 04.12.48.png
    Screen Shot 2015-08-06 at 04.12.48.png
    127.2 KB · Views: 368
Upvote 0
Top