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.

Similar Messages

  • Getting the current time and comparing it to a time in the future

    Hello,
    I am seeing in my research some debate on the best way to get the time. I am reading that just using the Date class and calling getTime() is not the most reliable way to do things. Overall, I am trying to get the current time down to the millisecond. I then want to add 5 seconds to that time and then store that value. FInally, when the current time is greater or equal to this stored value, I want to continue on in my program. Can anyone point me in the right direction on how to calculate the time variable? Any help would be much appreciated. I am new to the JAVA world.
    Thanks,
    Tim

    To store the current time, simply use new java.util.Date(). Yes, there might be slight inconsistencies and it might not be the most accurate time possible, but without significant additional effort (perhaps a native O/S call or the use of another time library), you will not do much better. Calendar won't help in this instance either. The easiest way to get five seconds in the future is to do the following:
    Date now = new Date();
    Date future = new Date(now.getTime() + 5000);To store and retrieve the value, it depends on what you are doing. You can place it in the database via JDBC (BTW, if you trust the database timestamp more than Java's you can use something like Oracle's SYSDATE instead of Java's date in your SQL query). You can place it in the filesystem. You can store it in the user's session.
    - Saish

  • How to get the current filename and & or path

    How can I get the current path or filename?
    I didn't really find any answers in the net. this.path or app.path were suggested but I couldn't get it to work.
    Thanks in advance for your answer!
    Livecycle Designer ES 8.2.1.3144.1.471865

    Hi,
    event.target.path.toString();  will give the full path including the filename.
    event.target.documentFileName.toString();  will give the filename only.
    Good luck,
    Niall

  • How to get the current cellid and areaid///

    i am undertaking a project as a part of my BE final year and urgently need information that how do we retrive the Base station name (in GSM mobiles network). are there any API's available??? plz do urgetly get back to me...or mail at my email id
    [email protected]
    [email protected]
    i got a new forums for me so ne suggestions or ideas you can leave your reply at
    http://getpass.netfirms.com
    Message was edited by:
    Manani Mitesh

    Not possible with any standard api's. You can do it if your phone support the ATCommand api, but 99% of the phones don't.

  • How to get the "current date" in the BEx?

    Hi all,
    I need to get the "current date" in my Bex report in order to make a comparison. I know there is a "How to" which shows how to get the current date via a User Exit, but I didn't find it. Could you please help me?
    Thanks

    1. Create a  New Formula in Key Figures structure
    2. Give tech name and description and Select "New variable" option
    3. Next screen will launch Variable Wizard -> create a new variable with replacement path as processing type
    4. in next screene  select the date characteristic that represents the first date to use in the calculation (From Date)
    5. In the next  screen select Key in the Replace Variable with field. Leave all the other options as they are
    6. In the next Currencies and Units screen select Date as the Dimension ID.
    6. Save variable
    repeate the Above steps to create another variable (To Date)
    and now you can use these two new replacement path variables in your new formula.
    Dev

  • How to get the Current Date in webdynpro java

    Hi Experts,
                 In my project i have two date input fields called
                        1)Start Date
                      2)End Date   
    and one Absence type input field is there. The user wants to set the start Date ,End date and absence type.
    How to get the user set values in my project.i.e how to get the user inputs and the started date must be current date of the system and end date must be after the 3 months.
    Can any body send code regarding this.
    Thanks in advance.
    Regards,
    Venkat.
    Edited by: Venkat5939 on Jan 11, 2011 4:46 PM

    Hello Venkat,
    Current Date:
    Date date = new Date(System.currentTimeMillis());
    For getting the date after three months refer the following threads:
    Set date in a date field
    Date Function
    date format
    Hope it helps.
    Regards
    Nizamudeen SM

  • How to get the current date ? in the form of dd/mm/yyyy?

    Hi all,
    As getDate( ), getMonth( ), and getYear( ) is depricated, how to get the current date or System date, month and year ? please help ??
    Regards
    Ashvini

    HI,
    Than u for the reply. But i am getting one error.
    as u said, I tried to do so.........
    but, i am getting one error.
    code
    Calendar cald=(Calendar.getInstance.getTime());
    out.println(cald);
    error message
    validate$jsp.java:86: Attempt to reference method getInstance in class java.util.Calendar as an instance variable.
    Calendar cald=(Calendar.getInstance.getTime());
    ^
    1 error
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
    Pls help
    Regards,
    Ashvini

  • How to get the current date in a workflow

    Hey,
    Can anyone tell me how to get the current date while in a workflow?
    Thanks in advance.

    Here is how we did it, hope it helps
    <defvar name='locCalendar'>
    <new class='java.util.GregorianCalendar'/>
    </defvar>
    <defvar name='dateFormat'>
    <new class='java.text.SimpleDateFormat'>
              <s>MM/dd/yyyy</s>
         </new>
    </defvar>
    <defvar name='formatedDate'>
         <invoke name='getTime'>
    <ref>locCalendar</ref>
    </invoke>
    </defvar>
    <invoke name='format'>
    <ref>dateFormat</ref>
    <ref>formatedDate</ref>
    </invoke>

  • How to get the current logged in username from windows and put it into an AS var

    Hello,
    I was hopeing someone would know how to get the current logged in username from windows and put it into a var, so I can create a dynamic text box to display it.
    Thanks in advance
    Michael

    Just for everyone’s info, this is the script I have used to get the logged in windows username into flash ---- not and air app.
    In the html page that publishes with the .swf file under the <head> section:-
    <script language="JavaScript" type="text/javascript">
    function findUserName() {
         var wshell=new ActiveXObject ("wscript.shell");
         var username=wshell.ExpandEnvironmentStrings("%username%");
         return username;
    </script>
    The ActionScript:-
    import flash.external.ExternalInterface;
    var username:String = ExternalInterface.call ("findUserName");
    trace (username); // a quick test to see it in output

  • Get the Current Quarter  and Current Week from date

    Hi,
    I want to get the Current quarter and Current week from a given date, which function modules should i use?
    I tried using function module - 'HR_99S_GET_QUARTER' for getting the quarter but it is throwing an error while loading data. Moreover it doesnt exist in BI7.
    Similarly for current week.
    Please help. Sample code snippets would be appreciated.
    Thanks
    Jaya

    You can use FORM time_conversion wich is the one used by standard in Update Rules:
    You can select whether convert 0CALDAY to 0CALWEEK or whatever infobject formats you prefer...
      perform time_conversion
                using  '0CALDAY'
                       '0CALMONTH'
                        p_input_date
                        l_fscvtval
                changing RESULT
                         c_t_idocstate
                         c_subrc
                         c_abort.
      if c_subrc <> 0 or c_abort <> 0.
        exit.
      endif.
    form time_conversion
                   using i_timnm_from type rsiobjnm
                         i_timnm_to   type rsiobjnm
                         i_timvl
                         i_fiscvarnt  type t009b-periv
                   changing e_timvl
                            c_t_idocstate  type rsarr_t_idocstate
                            c_subrc   like sy-subrc
                            c_abort   like sy-subrc. "#EC *
    data: l_timvl  type rsd_chavl,
          l_result type rsd_chavl.
      IF i_timvl CO ' 0'.
        CLEAR e_timvl.
        EXIT.
      ENDIF.
      l_timvl = i_timvl.
      CALL FUNCTION 'RST_TOBJ_TO_DERIVED_TOBJ'
        EXPORTING
          i_timnm_from             = i_timnm_from
          i_timnm_to               = i_timnm_to
          i_timvl                  = l_timvl
          I_FISCVARNT              = i_fiscvarnt
          I_BUFFER                 = rs_c_true
        IMPORTING
          E_TIMVL                  = l_result
        EXCEPTIONS
          INCOMPATIBLE_TOBJS       = 1
          NO_INPUT_VALUE           = 2
          FISCVARNT_MISSING        = 3
          INPUT_NOT_NUMERIC        = 4
          WRONG_DATE               = 5
          WRONG_FISCPER            = 6
          X_MESSAGE                = 7
          OTHERS                   = 8
      e_timvl = l_result.
    ENDFORM.                  "TIME_CONVERSION

  • How to Get the Current Workitem id at runtime

    Hi All,
    I have a scenario, where request pending with a user who has already resigned the organization. The requirement is that we need to provide a report
    of the request and with whom it is pending with along with the workitem id with a forward push button.
    So that if the user identifies that a request is pending with someone he can click the record and press for the forward button and a pop-up to be showed where he can enter the userid to whom he needs to forward it.
    In this scenario can anyone tell me how to get the current workitem id at run time and to save it to a custom table.
    I tried with method before workitem execution, but here i am not getting the current workitem id.
    Can you please suggest a good solution for this.
    Thanks and Regards,
    Balaji

    Karri,
    I think i can explain you with an example.
    Here is my Scenario.
    A user has raised a Gate pass and it went to all approval's and got approved and the material is also sent out from the plant. Lets take the date as 1.1.2013 (A Warehouse person have done the checking and sent out of the plant).
    On 1.3.2013 some of the material has been returned and a material inward request has been raised and now the warehouse person has to do a inward checking and to sent it back for the initiator for the approval, but the warehouse person has resigned the organization on 1.2.2013, now the workitem is pending with the warehouse person who has already resigned.
    My scenario is once the material inward request is created and before the workitem is delivered to the warehouse person i need to get the workitem id and to store the workitem some where.
    So that in future if any warehouse dept head wants to forward the workitem which are lying in the person inbox who has already resigned he can do it via a report using this workitem id.
    So, can anyone help how to get the dialog workitem id before the workitem creation or execution. I tried with "method before workitem execution" but my break point is not triggering at this point.
    Thanks and Regards,
    Balaji

  • How to Get the current month at timezone UTC-10

    Hi All,
       can you please let me know How to Get the current month at timezone UTC-10.
    Function module ? which date and time needs to pass.

    Hi,
    Try with following code.
    DATA zdate TYPE  D.
    DATA ztime TYPE  T.
                      CALL FUNCTION 'ISU_DATE_TIME_CONVERT_TIMEZONE'
                        EXPORTING
                          x_date_utc          = sy-datum
                          x_time_utc          = sy-uzeit
                          x_timezone          = 'UTC-10'
                       IMPORTING
                         Y_DATE_LCL          = zdate
                         Y_TIME_LCL          = ztime
                       EXCEPTIONS
                         GENERAL_FAULT       = 1
                         OTHERS              = 2.
                      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                      ENDIF.
    WRITE : zdate, / ztime.
    Thank you,
    Sekhar.

  • 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 get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • How to get the current slide Index or Id?

    I can get the selected slide of presentation use blow method.
    Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
    if (asyncResult.status == Office.AsyncResultStatus.Failed) {
    write('Action failed. Error: ' + asyncResult.error.message);
    else {
    write('Selected slides: ' + JSON.stringify(asyncResult.value.slides));
    But, How can I get the executor slide?

    ​Hi,
    >> How to get the current slide Index or Id?
    In my option, when you select a slide, it change to current slide. So, you could use the getSelectedDataAsync method to get the current slide, and then get the index or id by using the Slice object. You could refer the link below for Slice Object.
    # Slice.index property (JavaScript API for Office)https://msdn.microsoft.com/EN-US/library/office/jj715285.aspx?f=255&MSPPError=-2147217396
    Some key code as below:
    <script>
    function getText() {
    Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange,
    { valueFormat: "unformatted", filterType: "all" },
    function (asyncResult) {
    var error = asyncResult.error;
    if (asyncResult.status === Office.AsyncResultStatus.Failed) {
    write(error.name + ": " + error.message);
    else {
    // Get selected data.
    var dataValue = asyncResult.value;
    write('Selected data is ' + dataValue.slides[0].index);
    // Function that writes to a div with id='message' on the page.
    function write(message) {
    document.getElementById('message').innerText += message;
    </script>
    >> How can I get the executor slide?
    What do you mean by this? Is this a new issue which is different from the above issue? If so, I will recommend you post a new thread for this issue and share us more information about this.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

Maybe you are looking for

  • SD and Delivery objects Status checking

    HI Experts, In FI we have a transaction called FB99 to check whether the FI document is eligible for Archiving or not. Similarly , Do we have any transactions to check whether the given Sales , Invoice and Delivery documents are eligible for Archivin

  • Will Let's Edit run on Windows XP mode in Windows 7?

    I just purchsed an iMac and I want to load Windows 7 Professional onto it as well. We own the full version of Edius 5 but have not tried learning that program yet. I don't know if Edius 5 will run on Windows 7 but if I can still use Let's Edit I'll b

  • R3AD_CUSTOME and R3AD_SAL_ERR* are sysfail

    Hi Expert, SMQ2 --> R3AD_CUSTOME and R3AD_SAL_ERR* are sysfail in CRM2007 system. Status Text is displayed "Update BDoc status failed - BDoc not found" I deleted all queue in SMQ2 but recreate continuously. there are entries 987 now and then increase

  • Hi there, when will there be a support for the Olympus PEN E-PL7?

    Hi there, when will there be a support for the Olympus PEN E-PL7?

  • Mac won't partition?

    I had BootCamp working with my Windows and all of a sudden my windows crashed and wouldn't boot back up. It prompted me to restart it but wouldn't turn on still. Eventually, I got tired and used my USB to delete all partitions in my Crucial M5000 SSD