Add days to a date default of DateFields.

I'm creating a DateField with default date and add to my screen. How can I create a second DateField and add three days to the current date and displays?

Here is what it looks like when I open the screen initially:

Here's what I want it to look like:

Here is the code:

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
DateField dateStart = new DateField("", 0, sdf, Field.FIELD_RIGHT
        | DrawStyle.RIGHT | Field.FOCUSABLE) {
    protected void layout(int width, int height) {
        super.layout(100, height);
    };
};
dateStart.setMargin(new XYEdges(0, 15, 0, 0));
dateStart.setDate(Calendar.getInstance().getTime());
dateArea.add(dateStart);

DateField dateFinish = new DateField("", 0, sdf, Field.FIELD_RIGHT
        | DrawStyle.RIGHT | Field.FOCUSABLE) {
    protected void layout(int width, int height) {
        super.layout(100, height);
    };
};
dateFinish.setDate(Calendar.getInstance().getTime());

Hello

long ldate = System.currentTimeMillis();
String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date(ldate));

Gets the current date as long in ldate and as a string to a date.

If you want to add a day, simply add 24 * 3600 * 1000 to ldate. If you have the new date in milliseconds.

just convert to e string trick.

hope it helps

Tags: BlackBerry Developers

Similar Questions

  • How can I add days to a Date value in a Script time?

    How can I add days to a Date value in a Script (XPATH) time?

    XPATH:

    Add Date:

    xs:dateTime($yourCurrentDateVar) + xs:dayTimeDuration($yourDuration)
    

    Difference in date:

    move "fn:days-from-duration(xs:dayTimeDuration(xs:date($yourCurrentDateVar) - xs:date($yourPrevDateVar)))" to $diff;
    

    You did not mention the version of the Framework, you can take advantage of the Business Service (BS) to perform Date calculations, for example, for FW2.2.x, you can use BS: C1-DateMath with such options as the 'Resistance' to add to the Date, "DIFF" for Date-Diff and FW4.x, you can use BS: F1-DateMath with options such as "F1AD" to add to the Date etc.

    Find out more about XPATH herefunction.

  • Add days to a date

    Hello world

    I am trying to add a (x) number of days to a date.

    example: 15-Aug-2011 + 6 = 21-sep-2011

    I tried several things with calendar, but didn't workout, suspicion

    Not a trivial exercise and don't forget that you can just add 24 * 60 * 60 * 1000 for one time to add 1 day, because the day could be a breakthrough in 'day '.  If you want only the day and not the time, so it's a little easier.  Here's a hat of suggestions, I think that will work for you.

    Take the date, convert it to a Calendar object, use DateTimeUtiltiies to ensure that the time is 0 (that is 12:00 midnight) get the delay in milliseconds of this calendar (get the Date, then get the shape of time this Date), adding n * DateTimeUtilities.ONEDAY, where n is the number of days that you want to add, and then add 12, ensure that move you in the "next day" without taking into account DST changes that could happen in the period , then put it in the calendar, zero once again, the time and do it.

    If it does not, show us the code that you have developed.

  • Add days to a date is to be indented by year.

    Hello

    I have the problem on Oracle 10 g. I have run the following statement that adds 1 to a date, but, unless I have format, the date is back with a year less than expected.
    SQL> select effective_date, (effective_date + interval '1' year(1)) as addyear, add_months(to_date(to_char(effective_date, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'), 12) as addyearformat
       from price_change
            where
            price_change_id = '794328'   ;
    
    EFFECTIVE_DATE  ADDYEAR         ADDYEARFORMAT
    --------------- --------------- ---------------
    28-SEP-09       28-SEP-08       28-SEP-10
    Has anyone ever seen anything like that?

    Effective_date is of type date and has data in the format "MM/DD/YYYY HH24:MI:SS. I think it's something with the format, perhaps something to do with the zone - not sure. If I just insert a value into the table with the format ' MM/DD/YYYY HH24:MI:SS' I don't have this problem. I don't know how the date could have been modified to do that, but I know not to go through a time zone function before be inserted in this table, but I don't know if that is the cause of the problem.

    Don't know if it's important but nls_database_parameters...
    VALUE OF THE PARAMETER
    NLS_DATE_FORMAT dd-MON-rr
    NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
    NLS_TIME_FORMAT HH.MI. SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR


    Thanks for any help in advance.

    Published by: amcgator on October 15, 2010 11:52

    amcgator wrote:
    In fact, this would explain why, if I do not pass the end of the year mark (IE if I just add 30 days), everything looks OK. How in the world that is possible, or how can I confirm this?

    Did you read my response? Question:

    select  to_char(effective_date,'mm/dd/yyyy bc')
      from  price_change
      where price_change_id = '794328'
    / 
    

    If you see bc - it's confirmed :).

    SY.

  • Add days to a date that a new release date?

    Hello everyone, I'm trying to figure out how to add the days since a specific date of entry to the output of a new date.

    For example, the user inserts the date in cell 1 and cell 2 will be released on what date is 3 days later.

    Row1Cell2 = Row1.Cell1 + (3 days).

    So for example, if I return June 26, 2012, the output would be 29 June 2012... or if I get 29 June 2012 the output would be July 2, 2012.

    What is the correct syntax to use to produce this result?

    You can put this script on the output of your Cell1 event (script is FormCalc):

    David var = Date2Num($,"YYYY-MM-DD")

    Cell2 = Num2Date (David + 3, "YYYY-MM-DD")

    The date format should take on any model to date you have set, but you may need to change the structure of date above to match what you need.

  • Add days to a Date/time stored

    Hello

    Here's what I'm trying to do.

    I am trying to add a field of records called #Warranty_Dump_Info.Reference # on a domain registration
    called #Warranty_Dump_Info.Purchase_Date # and get a later date representing the date of expiry of a factory warranty.

    #Warranty_Dump_Info.Reference # is a numeric value (30, 90, 180, etc.) that represents the number of days covered by the warranty and the #Warranty_Dump_Info.Purchase_Date # is the date/time value (example: 2009-01-01 00:00:00)

    I can get the date/time format (time deleted).
    with the help of < foutput > #dateformat(Warranty_Dump_Info.Purchase_Date, "mm-dd-yyy") # < / output >

    However, I can't seem to add the number of days value of #Warranty_Dump_Info.Reference # or to display
    in the right format of date (time stripped).

    I tried the time of #Warranty_Dump_Info.Purchase_Date # stripping and then saving them as a variable, then
    always using the Functionadds on the variable, but it fails to strip the time according to the results.

    Thanks in advance for your help.


    In addition, what it means when the date is displayed as follows: {ts ' 2009-01-01 00:00:00 '}
    Some of my attempts to CF have resulted in this weird display "ts". You can see at the bottom of the page here: http://devo.dns2go.com/Warranty_Dump.cfm (logon as Admin, password: admin). That's where I tried to experiment and understand.

    OK, now I see what you're saying...

    I use CF functions in the SQL...

    Here are the labour code for those who follow this thread:


    SELECT *.
    INNER JOIN Vendor_Table WARRANTY
    ON Warranty.Vendor_Num = Vendor_Table.Vendor_Num
    WHERE dateadd (would be ', Warranty_Days, Purchase_Date) > = Date)
    AND Warranty.Part_Number ='#URLDecode (URL. "PartNumber) #
    ORDER OF Part_Number, Serial_number CSA

    Thank you very much for the help!

    Eric

  • Add days to date (integer format)

    Hi all

    I'm trying to add days to a date that is in numbers.

    Suppose I have a date 20140331 and if I add + 1 to her I me 20140332. How can I get 20140401 in digital format using pl/sql query.

    Also, I should be able to add any number of days existing dates to get the correct date. The example above is just a sample.

    Thank you

    Hello

    Here is an example showing how easy it is to use the arithmetic of dates with DATEs:

    CREATE TABLE table_x

    (x_id PRIMARY KEY NUMBER

    x_date DATE

    );

    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYYMMDD ';

    INSERT INTO table_x (x_id, x_date) VALUES (1, TO_DATE ('20140331', 'YYYYMMDD'));

    INSERT INTO table_x (x_id, x_date) VALUES (2, SYSDATE);

    SELECT x.*

    x_date + 1 tomorrow

    x_date + 10 AS ten_days

    FROM table_x x

    ORDER BY x_id;

    Output:

    X_ID X_DATE TOMORROW TEN_DAYS

    ---------- -------- -------- --------

    1 20140331 20140401 20140410

    2 20150219 20150220 20150301

    Date arithmetic is also easy and intuitive, when using the DATEs as a number arithmetic is using numbers.

  • How to add days, hours, minutes and seconds to a date?

    Hello

    I have the following problem.
    Saw 4 integers D, H, M, and S (each of them can be negative) and a date Da, I want to add days D, H hours, M minutes and seconds of S date Da.
    For example, if
    Da= to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss'), and D = 3, H = -2, M = 20 and S = -12, 
    This means that I want to add 3 days, -2 hours, 20 minutes and -12 seconds to the date Da, and the new date must be in the following date:
    to_date('01/07/2011 13:10:23','dd/mm/yyyy HH24:mi:ss') 
    Is it possible to write a query for this problem or should I use PL/SQL?

    Thank you.

    There is no need of PL/SQL

    SQL> alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
    
    Session altered.
    
    SQL> var d number
    SQL> var h number
    SQL> var m number
    SQL> var s number
    SQL> exec :d := 3; :h := -2; :m := 20; :s := -12
    
    PL/SQL procedure successfully completed.
    
    SQL> select to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss')
      2     + :d
      3     + (:h / 24)
      4     + (:m / 24 / 60)
      5     + (:s / 24 / 60 / 60)
      6  from dual;
    
    TO_DATE('28/06/2011
    -------------------
    01/07/2011 13:10:23
    
  • How do I add 7 days to a date and compare it to the current date in a cfquery?

    I have classes that are no longer active once after the date of the class. However, the class should be displayed for seven days more in the backend. I tried to use the script below to get there, but I get an error "Variable DATE is not defined." I'm going in the right direction or is there a better way to do this?

    < name cfquery = "getClasses" datasource = "#application.dsn #" >

    Select *.

    (break the classReg INNER JOIN classReg.classID = classes.classID) INNER JOIN instructors ON classreg.instID = instructors.instID

    <!-adding seven days to the date of the class (date) by comparing the current date->

    where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.

    < / cfquery >

    where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.

    As Coldfusion said you, quite rightly so, he knows no variable called "date". You're in a request and, apparently, 'date' is a column name. So use the SQL functions instead of Coldfusion functions.

    In MySQL, the appropriate where clause is:

    WHERE DATE_ADD (date, INTERVAL of 7 DAYS) > CURDATE)

    In SQL Server, the appropriate where clause is:

    WHERE DATEADD(day,7,date) > GETDATE()

    ---------------------------------

    Afterthought: I would rename the column 'date', as it is a reserved word in some database management systems

  • How to display a given date in a DateField?

    Hi Experts,

    I'm developing an app for BlackBerry in Java. I want to display a date I will give statically for example "October 4, 2008. I did, but while reading, it is displayed in January 1, 1970. How can I display a static date in a DateField?

    Thank you and best regards,

    Nithya

    Simple use.

    import java.util.Date;

    Net.rim.device.api.i18n import. *;

    String date = new SimpleDateFormat("dd/MM/yyyy_hh:mm").format (new Date (System.currentTimeMillis ()));
    Add (new RichTextField (date));

  • Dynamic calculation of the number of days between two dates in a table

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    Hi BO123,

    BO123 wrote:

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    one of the way to do this by calling ajax on change of end_date.

    See the sample code given below to fetch the resulting duration and making the field read only after calculation

    Step 1: Change your page

    under CSS-> Inline, put the code below

    .row_item_disabled {
      cursor: default;
      opacity: 0.5;
      filter: alpha(opacity=50);
      pointer-events: none;
    }
    

    Step 2: Create on demand Ajax process I say CALC_DURATION

    Please check Procces Ajax, see line 6.7 How to assign a value to the variable sent by ajax call

    Declare
      p_start_date  date;
      p_end_date    date;
      p_duration number;
    Begin
      p_start_date  := to_date(apex_application.g_x01);
      p_end_date    := to_date(apex_application.g_x02);
    
       --do your calculation and assign the output to the variable p_duration
      select p_end_date - p_start_date into p_duration
        from dual;
    
      -- return calculated duration
      sys.htp.p(p_duration);
    End;
    

    Step 3: Create the javascript function

    Change your page-> the function and the declaration of the Global Variable-> put the javascript function

    You must extract the rowid in the first place, for which you want to set the time, see line 2

    assuming f06, f07 and f08 is the id of the start date, and end date columns respectively, and duration

    See no line no 8 how set the value returned by the process of ajax at the duration column

    Replace your column to the respective column identifiers in the code below

    function f_calulate_duration(pThis) {
      var row_id  = pThis.id.substr(4);
      var start_date = $('#f06_'+row_id).val();
      apex.server.process ( "CALC_DURATION", {
      x01: start_date,x02: $(pThis).val()
    }, { success: function( pData ) {
    // set duration to duration column
    $('#f08_'+row_id).val(pData);
    // disable duration column
    $("#f08_" + row_id).attr("readonly", true).addClass('row_item_disabled'); }
    });
    }
    

    Step 4: choose the end date call the javascript function

    Go to report attributes-> edit your Date column end-> column-> Attrbiutes element attributes-> put the code below

    onchange="javascript:f_calulate_duration(this);"
    


    hope this helps you,

    Kind regards

    Jitendra

  • Disable certain days in the date picker

    Hi, I use Apex 4.2 and want to find a way to disable certain days in the date picker.

    For Ex: I want to turn off Mondays and the days of the week when the date picker popup is shown. And also I want all the previous days from today should be disabled.

    Please let me know how I can do this...

    Thank you

    Hello

    to disable different days look at this site: http://jquerybyexample.blogspot.com/2010/07/disable-specific-days-in-jquery.html

    To deactivate the days in the past, add this in: settings > Minimum Date: + 0d

    See you soon,.

    Tobias

  • ALTER Table Add column not null, no default

    I want to add two columns in a table with not null, and the default value 0 for two columns
    Can I write everything in a single statement or do I have to divide the declaration
    I tried, but didn't work

    ALTER table DWSODS01. DWT00301_ORD_DTL_OMS add)
    COMB_ORD_FLG NUMBER (5.0) default null, 0
    COMB_ORD_NO NUMBER (12.0)
    by default, 0 not null);

    How can I change the code?

    user10390682 wrote:
    OK, so if it is NOT NULL, while there should be a value.

    Yes.

    So, when I set these two columns as NOT NULL will only future data must be NON NULL.
    What of the old and present data if I defined as NOT NULL

    NOT NULL mean value of eachcolumn + line (current or future) _ must not be null. That's why always adding NOT NULL column to a non-empty table fails - the column value for existing lines will be NULL which does NOT violate the constraint nullability. If you add the NON NULL column with a default value, the column will be added and all lines existing column value will be defined by specified default (0 in your case). As a result Oracle will be able to settle forced to null for this newly added column from the value of this column in all the existing lines will be not not null (0 in your case).

    SY.

  • get the name of the day of a date (format yyyy/mm/dd)

    Hello

    In blackberry java application development is possible to get the name of the day of a date (format yyyy/mm/dd).

    I have a date as 09/15/2013. I want the output like Sunday

    Thank you and best regards.

    Thank you reply Erwan fo...

    I post my code using... It can be used to get the name of the day for a date string.

    //SimpleDateFormat write = new SimpleDateFormat("EEEE-MMM-dd");//It will return Weekday name as full plus monthe name plus date
    SimpleDateFormat write = new SimpleDateFormat("EEEE");//It will return Weekday name
    Date date = new Date(HttpDateParser.parse("2013/09/12"));
    System.out.println(write.format(parsedDate));
    

    Best regards.

  • Add the Menu item to default custom Blackberry file browser

    Hello

    I try to add the Menu item by default Blackberry file browser.

    I want to add the menu item 'PRINT' files. It is when I browse through the media-> Explore-> photo, we get a list of images and when clicked on the Menu. I expect the element menu to print it.

    I use ApplicationMenuItemRepository to achieve this. And the documentation says.

    MENUITEM_FILE_EXPLORER
              ApplicationMenuIteminstances registered with this ID appear when the file Explorer application is running.

    MENUITEM_FILE_EXPLORER_BROWSE
              ApplicationMenuIteminstances registered with this ID appear when a user uses the Windows Explorer application to browse files and folders.

    MENUITEM_FILE_EXPLORER_ITEM
              ApplicationMenuIteminstances registered with this ID appear when a user uses the file Explorer application to open a file.

    Whence this Explorer of files mentioned in the CIHI means. I added the Menu item in the browser, and I could see the IMPRESSION here. But I don't know where this IMPRESSION would be visible IF we add the menu item to one of them.

    Thanks in advance.

    Provision ApplicationDescriptor solved my problem.

Maybe you are looking for

  • The response of Mac is too slow

    The response of Mac is too slow, I have to reset DRAM, RAM, or memory NVRAM? Or y at - it another way to solve this problem?

  • NOR-DAQmX hardware synchronization for module 2 OR-9223.

    Dear all I use NEITHER cDAQ 9184-2 NOR-9223(1M) analog acquisition module 6 input channels of the sensors of acoustic emission (frequency of 20 to 400) with external signal conditioning. Please please let me know how to synchronize using NOR-DAQmX? N

  • Class modules McciSysSecurityCenter

    Hello My computer (XP) has constantly blocked (not responding).   I have a plethura of class modules McciSysSecurityCenter and I think that they are creating a problem with IE8.  Is it possible, add-ons, I should turn on and turn off?  I tried to dis

  • vFoglight, vRanger connection &amp; vCenter

    Hi all.We have recently updated our virtual environment for vSphere 4U1 with 6 blades connected in vCenter ESX.We currently have vRanger connection and vCenter installed on the same physical machine attached to the San. He is currently a backup ok.My

  • How can I get F1 - F12 standard mode

    I have a Toshiba Satellite (L855-S5240) and you have a question about my F (F1 - F12) keys and my Fn keys. I play an online game where some interfaces are mapped to the F keys. It is quite annoying to have to hold down the Fn key and then press F4 to