How to compare the current system time with two timing?

want to get the current system time and compare with the two different timing example startwindow time as 2:00:00AM and endWindowTime as 6:00:00AM. if my current system time falls between these window i have to execute my rest of the code.
my below code works for fine for JAVA 1.6 version when i do the same code with JAVA 1.4 i am getting different date and time
String starTime=(String) NightlyvendorStatus[0].getPropertyValue("startTime");
  String endTime=(String) NightlyvendorStatus[0].getPropertyValue("endTime");
  Date windowStarttime = new SimpleDateFormat("HH:mm:ss").parse(starTime);
  Date windowEndtime = new SimpleDateFormat("HH:mm:ss").parse(endTime);
  Date systemdate = new Date();
  SimpleDateFormat parser = new SimpleDateFormat("HH:mm:ss");
  String systemTime=parser.format(systemdate);
  Date currentTime = new SimpleDateFormat("HH:mm:ss").parse(systemTime);
  if (currentTime.after(windowStarttime) && currentTime.before(windowEndtime)){
--- rest logic here---}
the output from JAVA 1.4 IS Thu Jan 01 02:00:00 GMT 1970 Thu Jan 01 06:00:00 GMT 1970 Thu Jan 01 03:23:00 GMT 1970
HOW TO DO this logic..

Hi,
You can try converting dates into timestamp and compare just like as comparing two integers variables.
Regards,
Anshul

Similar Messages

  • Re: incrementing the current system time with 30 minutes

    hi
    in JSPinner i need to display the time but that time should be 30 min greater than system time
    is that possible
    reg
    vino

    1. Create a GregorianCalendar instance
    2. Use roll() to add 30 minutes
    3. Use getTime() to convert to a Date instance

  • How cost;ly it is to get the current system time

    I am using this call "System.currentTimeMillis()" to get the current system time. I need to now how costly it is to get the current system time.

    Why don't you time it -:) Run it 10000 times and print the first and last result. The difference is the time it took.

  • CALCULATE 6 MINS FROM THE CURRENT SYSTEM TIME....................?

    Hi
    I want to subtract few mins (say 5 min , 10 min ,15 mins , max to 55 mins) from the current system time,
    ex-current time 00:40:00
    Subtract 5 mins(means 5 mins backward)
    Final time 00:35:00
    ex-current time 01:20:00
    Subtract 30 mins(means 30 mins backward)
    Final time 00:50:00
    Pls help me with this with a appropriate logic or FM..
    Thanks a lot in advance
    Basic Date and Time questions are not allowed. They have been answered umpteen times. Please search for them.
    Edited by: kishan P on Sep 1, 2010 12:05 PM
    Edited by: Matt on Sep 1, 2010 9:01 AM - And please do not post in ALL CAPITALS

    May be you can do something like this!
    data: l_time like sy-uzeit.
    data: l_time1 like sy-uzeit value '06'. "6 hrs to be deducted from system time
    move sy-uzeit to l_time. "this is system time
    "write l_time.
    "write:/ l_time1.
    SUBTRACT l_time1 from l_time.
    write:/ l_time. "This is 6 hrs behind system time
    Rajasekhar

  • CALCULATE 6 HOURS FROM THE CURRENT SYSTEM TIME....................?

    hi
    good
    i want to subtract 6 hours from the current system time,
    ex-current time 17.07
    Subtract 6 hours(means 6 hours backward)
    Final time 11.07
    Pls help me with this with a appropriate logic.
    Thanks a lot in advance
    mrutyun^

    May be you can do something like this!
    data: l_time like sy-uzeit.
    data: l_time1 like sy-uzeit value '06'. "6 hrs to be deducted from system time
    move sy-uzeit to l_time. "this is system time
    "write l_time.
    "write:/ l_time1.
    SUBTRACT l_time1 from l_time.
    write:/ l_time. "This is 6 hrs behind system time
    Rajasekhar

  • How to get the current GMT time in java

    Hi,
    How to get the current GMT time in java
    Thanks

    System.getCurrentTimeMillis() or new Date().
    [url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
    [url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format

  • How to compare the current date to an inputed date?

    I am having a validation to check if the date is not After the current System Date?
         public String getDate_trans()
             try {
             Date x=new Date();<<Get the current Date
             Date date=new Date();
             DateFormat formatter ;
             formatter = new SimpleDateFormat("yyyy-MM-dd");
             date = (Date)formatter.parse(date_trans); <<<Inputed Date
                   System.out.println(date);
                   System.out.println(x);
                   if(date<x)
                        System.out.print("Date is Valid");
                                                   else
                                                     System.out.print("Date is invalid");
             catch (ParseException e)
        {System.out.println("Exception :"+e);    }
         return date_trans;
         }

    tr3k wrote:
    I dunno what to method to use in there...I'm so sorry...The closest method that I could use I think is the compareTo...but I dunno how I can use that to compare using greater than or less than.....Read the docs for that method. READ THE DESCRIPTION. What do you not understand about that?
    And there are two other methods that are even simpler. You haven't looked closely enough.

  • How to verify the  Source systems connectivity with BWQ System.

    Hi All,
    I have diff source systems. And my requirement is to check the source systems connectivity with BWQ (BW Quality sys). please any body tell me the steps how to check the source system connectivity ?
    Thanks & Regards,
    Manju

    Hi Manjula,
    If you encounter problems when establishing a connection to your target server, check the following:
    A message box appears while performing one of the following actions:
          Setting connection by choosing Apply to local session.
          Testing connection settings by choosing Test settings.
          Creating SAP TSQL objects
    If errors occurred, they are displayed in the respective message box.
       Check developer trace files in ST11.
      Test connection:
         For RFC related errors, check the RFC connection via SM59
         For database multi-connect errors, check if you can connect to the target SQL Server with the SQL Server Query Analyzer. Also check if the DBCON entries are correct.
    Regards,
    RK

  • How long is the start up time with macbook pro retina?

    I just bought a new 13 inch macbook pro with retina display.  It is using osx mavericks.
    It takes about 21 seconds to start up.  I watched a demo on youtube and the demo showed it should take about 12 seconds to start up.
    I have two users on the computer and each user requires a password.  Would that take it longer to start up?  The demo had one user and it didn't require a password.
    I also briefly had sophos antivirus installed but uninstalled it.  I don't know if this could have slowed it down, but it is off the computer now. I also have the firewall turned on...could this slow it?
    Thanks for any input!

    AppleCare will only replace your battery if it has significantly lower than expected capacity within one year of buying. After a year it's not covered.
    Your battery's capacity very much depends on how you treat the battery. If it's always in a hot environment and if you're always draining the battery to 0% charge (two things that decrease Lithium-Ion battery life), then the capacity that you have is not too surprising.
    You could try calling AppleCare but I don't know that you'll get anywhere with them considering that it's been more than a year.
    -Eric

  • How tall are the current Macbook Airs with lid open?

    I ask this because I'm interested in buying the 11" or 13" and want to position a monitor behind it but it needs to be higher than the screen of the Air.

    It's going to vary a little depending on the angle of the screen but my 2011 13" Air is 9" high with the screen at a 90º angle.

  • How to get the current date and compare dates

    hi
    does anyone know how you would get the current date?
    furthermore, how to compare the current date with a past date to see how many days or months have past since then?
    thanks

    have a look at the Date class. new Date() creates an object containing the exact date and time at creation time. (Date).getTime() might be useful for comparing two dates. GregorianCalendar might be useful, too.

  • How do i plot with the operating system time in one plot and show lines between cursors in another using the same XY graph?

    I am having some trouble graphing two plots at once. One plot is to show the current temperature inside a chamber as a function of time. I am trying to pick the current time and temperature each second and plot it with each point being connected by a line. I am able to show a moving, blinking dot each second but I can't figure out how to develop an actual line with these dots. To make matters worse, the blinking dot is back in the year 1903. I understand that it uses seconds elapsed since 1903, and am trying to find out how to graph the current temperature with the system time.
    The second plot is just 5 moveable cursors that are to be connected by a line. I am able to move the cursors and retrieve the position information, but I can't make a line between them.
    I have attached my main .vi, though you may have to pick the graphing part off to have it work for you.
    Attachments:
    Main Module Chamber Testing I_O every 30 sec.vi ‏288 KB

    You're not creating the XY graph data correctly. I've attached an example with a couple of simple XY Graphs. One is using a couple of shift registers to hold the spearate x and y arrays. I think this is what you were trying to do. The other one uses a VI from the shipping examples called XY Chart. It makes an XY Grpah act like a chart. I've also shown the correct way to display current time.Message Edited by Dennis Knutson on 05-12-2005 03:51 PM
    Attachments:
    XY Graph.vi ‏41 KB

  • How to check the current time with a Stored  time in string format

    Hi All
    I would like to compare the system time with an existing time values which is allready there in String format..
    i mean i would like to check if the SysTime is inbetween 6:30 and 14:00
    I accomplished this in Oracle ..
    Select 'Y' from dual where to_date(to_char(sysdate,'HH24:MI '),'HH24:MI') between to_date('06:30','HH24:MI') and to_date('14:00','HH24:MI')
    But instead of checking the DB each and every time , the perfomance would be better if we can do this in our java code..
    Could some one provide me with a code to accomplish the above scenario..
    Thanks in advance..,.,

    import java.util.Calendar;
    Calendar rightNow = Calendar.getInstance();  // gets the current date and time to millisec
    Calendar earlyTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 6).set(Calendar.MINUTE, 30);
    Calendar lateTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 8).set(Calendar.MINUTE, 0);
    if (rightNow.compareTo(earlyTime)> 0 && rightNow.compareTo(lateTime) < 0){
    // do something
    }Try this.

  • How to cooperate the current mail system with Sun Java Commnication Suite 5

    Dear all and Shane,
    Excuse me for bothering you again.
    Due to time limited, I would like to know how to cooperate the current mail system with Sun Java Commnication Suite 5. I mean I would like to use current mail system (mailscanner + postfix + courier-IMAP + clamav + spamassassin + webmail) and use the outlook connector to connect to Sun Java COMMS 5 to share the calendar, contacts only.
    Right now I have done the testing by using outlook, mac mail, thunderbird to share calendar,contacts via Sun Java COMMS 5 in Centos Linux 5.
    My plan is as following
    1. Sun Java Communication suites 5 server ( I called it comms5 ) will be in DMZ zone and will open the necessary ports in firewall.
    2. I will create more than six sub domain name in Sun Delegate server and the necessary accounts within these domain names.
    3. All messages will be transmitted via Postfix and clients will retrieve from Courier-IMAP
    4. All Clients included other branch offices will use different mail clients to share their calendars, contacts via COMMS5 ( But how will COMMS handle the messages such like invitation ? )
    Any suggestions will appreciate.
    PS: Is it possible to classify the contacts in outlook address book ?
    For example, when user click the receiver, it will show like as following
    GLOBAL ADDRESS BOOK
    --Director
    --and so on
    ----CN.BRANCH OFFICE
    -----------CN01 EMAIL ADDRESS
    -----------CN02 EMAIL ADDRESS
    -----------CN03 EMAIL ADDRESS
    and so on
    ----JP.BRANCH OFFICE
    -----------JP01 EMAIL ADDRESS
    -----------JP02 EMAIL ADDRESS
    -----------JP03 EMAIL ADDRESS
    and so on
    ----TW.BRANCH OFFICE
    and Due to the user account is located in CN.BRANCH OFFICE, it will extend the CN.BRANCH OFFICE contacts level.
    Excuse me for bad English, hope you can understand it.
    Best Regards,
    Bruce

    Dogz wrote:
    Due to time limited, I would like to know how to cooperate the current mail system with Sun Java Commnication Suite 5.
    I mean I would like to use current mail system (mailscanner + postfix + courier-IMAP + clamav + spamassassin + webmail) and use the outlook connector to connect to Sun Java COMMS 5 to share the calendar, contacts only.Getting your current mail system to 'co-operate' in this way will require more time then simply migrating the accounts of users on the current mail system to the comm-suite-5 installation and making use of UWC for Webmail access and ClamAV/SpamAssassin integration within the messaging MTA.
    Also the use of Outlook Connector with a non-Sun IMAP backend isn't supported, nor is the use of a non-Sun IMAP backend possible with UWC.
    Right now I have done the testing by using outlook, mac mail, thunderbird to share calendar,contacts via Sun Java COMMS 5 in Centos Linux 5. Once again I should remind you that CentOS is not a supported platform for comm-suite-5
    Regards,
    Shane.

  • How to pass Current System time in the target field?

    Hi Experts
    kindly help me in mapping a field in which I have to map current system time.
    I think there is no standard function for time like the date so do i write a UDF for the same or any other way an in case a UDF than please help in that.
    Thanks
    Aprajita

    Hi Mathur,
    kindly help me in mapping a field in which I have to map current system time.
    I think there is no standard function for time like the date so do i write a UDF for the same or any other way an in case a UDF than please help in that.
    Mathur no need to write UDF for that..
    Use standard function Current date-------> In that (Target Format) u have to specify the time i.e: HHmmss
    Thats it..... Noe use this function as u like...
    Satya Kumar

Maybe you are looking for