18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to Convert String to Integer in SAHI

SreekanthSreekanth Members
edited February 2013 in Sahi - Open Source
Hello All,
how do you convert value in a variable to integer in sahi.
Searched the forum for this , but dint find a solution. i tried using intval , Integer.parseInt etc... but they dint work.


my basic problem is not this. i wanted to get value of current month, used following.

$month = $msgdatetime.getMonth();
if ($month < 10)
{
$month = "0" + $month;
}


The problem is that its giving me value of previous month.
for example, if i do this function today (Feb 1st 2013), the value i am getting is 01.
yesterday it was giving me 00.

So, i thought of converting the value in $month to an int and then adding it by 1.
may be not the best thing to do, but can i get any help on this ?

my OS is windows 8.
sahi version is (Build: 2011-07-19).
and browser is firefox 17.


Regards,
Sreekanth.



Best Answer

  • edited February 2013 Answer ✓
    Hi Sreekanth,

    could you try using this one if it will work for you,
    var $now = new Date();
    $month = String("0" + $now.getMonth()).slice(-2);
    

    It will return the integer value of the month.

Answers

  • Hi lonely_girl01 ,

    Thanks for the reply,

    I got a result by doing this.
    $month = $iddate.getMonth();
    $month1 = parseInt($month);

    Will try your way too.
    Thanks :)
Sign In or Register to comment.