How to add minutes to date in java

I have date in string variable, i have to add/subtract minutes from it, please adivce , how i could do in java 1.5
sample data
String olddate = "12/16/2010 4:58:29 PM"
String minutes1 = "300"
i would like to get value as below for above data
String newdate ="12/16/2010 9:58:29 PM"

Use SimpleDateFormat to convert the date object to string. Once the string object converted to date object use the getTime() method to get the date in milliseconds.
Now you can easily adds/substract the date object.
Remember, the resulting long value from getTime() method is in milliseconds, to get the value in minutes you need to multiply it by 1000 and by seconds in a minutes, that is 60.
When your subtraction/adds done convert it back to date object.
This is the codes:
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
public class DateCalculator {
     public static void main(String[] args) throws ParseException {
          String olddate = "12/16/2010 4:58:29 PM";
          System.out.println("old Date: "+olddate);
          SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");
          long oldDateInMillis = formatter.parse(olddate).getTime();
          String minutes1 = "300";
          String newDateAdds = formatter.format(new Date(oldDateInMillis + Long.valueOf(minutes1)*1000*60 ));
          String newDateSubstract = formatter.format(new Date(oldDateInMillis - Long.valueOf(minutes1)*1000*60 ));
          System.out.println("new Date [Additions] : "+newDateAdds);
          System.out.println("new Date [Substraction] : "+newDateSubstract);
}

Similar Messages

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • I want to add image in column is it possible then how to add image in data base what data type we need to do

    I want to add image in column is it possible then how to add image in data base  what data type we need to give we required any casting  please show me one example
    jitendra

    Hi again,
    Several points that can help more:
    1. If you are working with Dot.Net, then I highly recommend read the first link that you got! This is nice and simple coding. Another option is this link which is even better in my opinion:
    http://www.dotnetgallery.com/kb/resource21-How-to-store-and-retrieve-images-from-SQL-server-database-using-aspnet.aspx
    2. As i mention above both link use the column's type image. There are several other option of working with Files. In most of my applications architecture I find that it is better to use a column which let us use any type of file and not an image column.
    In choosing the right column's type for your needs basically your fist question should be if if you want to store your data inside relational database environment or outside relational environment. It is a good idea to look for blogs on this issue. Next
    if you chose to store your data inside then you need to chose the right column type according to your server version. I highly recommend to look for blogs on the differences between those column's types: IMAGE, 
    Check those links:
    To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem
    http://research.microsoft.com/apps/pubs/default.aspx?id=64525
    FILESTREAM feature of SQL Server 2008
    http://msdn.microsoft.com/library/hh461480
    FileTables feature of SQL Server 2012
    http://technet.microsoft.com/en-us/library/ff929144.aspx
    Compare Options for Storing Blobs (SQL Server)
    http://technet.microsoft.com/en-us/library/hh403405.aspx
    Binary Large Object (Blob) Data (SQL Server)
    http://technet.microsoft.com/en-us/library/bb895234.aspx
    Managing BLOBs using SQL Server FileStream via EF and WCF streaming
    * Very nice tutorial!
    http://petermeinl.wordpress.com/2012/02/20/managing-blobs-using-sql-server-filestream-via-ef-and-wcf-streaming/
    [Personal Site] [Blog] [Facebook]

  • How to add a new data type of oracle to SIM(7.0)

    Hi........
    I need to add a new data type(CLOB) to SIM of oracle .can anyone tell me how to modify or add this new data type.
    Any pointers to this will be highly appriciated.......
    thax in advance...

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • How to add more summary data in the MIP of Compensation workbench

    Hi all,
    In the MIP (incentive plan) of the compensation workbench, we need to add more summary data in the summary section. I checked that all the summary data in that section are stored in the table 'ben_cwb_summary'.
    Even we can change the VIEW object for that page (using extension), we can't retrieve it because the new summary data/information we need to add are not stored in the table 'ben_cwb_summary'. We need to write our query to summerize data.
    How to implement it?
    Thanks in advanced!
    Jane

    faiz2000 wrote:
    > How to add more one record in the same time?
    >
    > Please I need your help to add more one record in the
    same time, how can I do
    > that?
    >
    > I have only one text field and the value it is linked
    from other table, if
    > user he bushes bottoms the all data it will copy it to
    new record:
    >
    > Ex.: <input name="textfield" type="text"
    >
    value="<%=(Recordset1.Fields.Item("webgroup").Value)%>">
    >
    >
    Use "Repeat Region"
    Mick

  • How to add Abab stack to exiting Java stack

    Hi All,
    I am having a netweaver Java Stack installed on my system. I would like to install XI - in order to install Xi ,I guess the system should be ABAP + Java. But since I am having java based engine, I would like to add ABAP stack to it. So, my question how to add an ABAP stack to already existing JAVA/J2ee engine.
    So what this process is known as-- Is it upgrading or New Installation. Because I need the guide and CD's for it.
    Can any one tell me which Guide(Install/upgrade/Master) wud help me.
    Thanks
    S

    Hello
    If you are adding XI 7.1 check this page: http://service.sap.com/~form/sapnet?_SHORTKEY=01100035870000702775&_SCENARIO=01100035870000000202&
    If you are adding XI 7.0 check this one: http://service.sap.com/~form/sapnet?_SHORTKEY=01100035870000659894&_SCENARIO=01100035870000000202&
    You should read the master guides and install the new usage type on top of your current installation but check the SAP notes about it first.
    If what you want is to install XI 3.0, that is if you have an existing v6.40 java stack, I think the operation is not recommended/supported by SAP, you should install a separate instance.
    Hope it helps.
    -Sam.

  • CWB: how to add more summary data in the summary section

    HI All,
    We need to add more summary data in the summary section. Some summary data need to calculated dynamically like (summary data A /summary data B).
    under the worksheet, there is a link:
    Personalize Dynamic Columns
    But this link allows to create Dynamic Columns for the worksheet, but not for summary setion.
    Is any way to add more summary data in the summary section through personalization instead of customization (VO extension)?
    Thanks in advanced!
    Jane

    faiz2000 wrote:
    > How to add more one record in the same time?
    >
    > Please I need your help to add more one record in the
    same time, how can I do
    > that?
    >
    > I have only one text field and the value it is linked
    from other table, if
    > user he bushes bottoms the all data it will copy it to
    new record:
    >
    > Ex.: <input name="textfield" type="text"
    >
    value="<%=(Recordset1.Fields.Item("webgroup").Value)%>">
    >
    >
    Use "Repeat Region"
    Mick

  • How to Add Time in Date

    hi,
    how to add time in a date for example
    date='01-jan-2005 23:00' [dd-mon-yyyy hh24:mi]
    time (to add)='02:00' [hh24:mi]
    if any one hv any idea about. pls reply

    If you can get the time element into an INTERVAL DAY TO SECOND datatype, you can simply add the interval to the date, e.g:
    yourdate + NUMTODSINTERVAL(2,'HOUR')
    What is tricky is converting a string like '02:00' into an interval or a number. You could generate a numeric offset with something like:
    TO_DATE('02:00','HH24:MI') - TO_DATE('00:00','HH24:MI')
    which can then be added to the date
    SELECT TO_DATE('01-jan-2005 23:00', 'dd-mon-yyyy hh24:mi') +
           (TO_DATE('02:00','HH24:MI') - TO_DATE('00:00','HH24:MI'))
    FROM   dual;

  • How to add event in Date type bean

    Hi,
    I have created two date items - start date and end date.
    now I want to add event in these items?
    how can I add event in date type bean?
    Pls help..
    Thanks
    Amit

    Hi Swati,
    Yes, I have two OAMessageTextInput bean of Type Date.
    How can I set event by --StartDateBean.setEnterClientAction(ClientAction);
    I am unable to pass parameter of type "ClientAction" in .setEnterClientAction.
    how can I do this. If I declare by
    ClientAction DateEvent = null;
    then
    StartDateBean.setEnterClientAction(DateEvent);
    then it doesn't gives me any error but I am unable to initialize the value in "ClientAction" except null.
    How can I do this?
    Pls Help?
    Thanks
    Amit

  • How to add a hide data into an appointed image of the pdf

    Can I add data into an appointed image and hide the data?
    if can not add hide data in image, can I  add hide the data into the other layer  of   the pdf?
    Can anybody give me some tips?
    thanks!

    My code:
    ASFile hddatFile = NULL;
    ASPathName hidedataFile = ASFileSysPathFromDIPath (ASGetDefaultFileSys(),  "e:/myInfo.txt", NULL);
    if (hidedataFile == NULL)
         AVAlertNote("not yet");
    ASInt32 hidedataVal = ASFileSysOpenFile(NULL, hidedataFile, ASFILE_READ, &hddatFile);
    if (hidedataVal != 0)
         AVAlertNote("隐藏数据加载失败!");
    CosObj imgCos;
    PDEImageGetCosObj(pdeImage, &imgCos);
    CDocument cDocument;
    ASAtom Seal_K = ASAtomFromString("ADBE:Mytest");
    CosDictPut(imgCos, Seal_K, CosNewInteger((CosDoc)cDocument, false, ASFileGetEOF(hddatFile)));
    I'm not sure whether I have set the hide data in the picture success? there is not a return value to know it.
    when I use this code to get data:
    CosObj stream;
    PDEImageGetCosObj((PDEImage)pdeElement, &stream);
    CosObj nameCosObj = CosDictGet(stream, Seal_K);
    the return value (nameCosObj is (0,0)).  I dont know why? and if I get the cosObj, How to get my hide data?
    Where I do wrong?
    thanks for Leonard !

  • How to add minutes to pay as you go phone

    I'm probably missing something really obvious but I just want to add minutes to my phone online and I can't find a link anywhere, every one I click takes me to my account page where there is no option to refill.
    Any help would be great!

    Do you have a password and are you signed up on the prepaid wireless page?? After you put in your cell 10 digit  number you need to put in your password then a page will come up that will give you options on how to refill, either by using a prepaid cell card, or auto pay or buying the prepaid card or credit card.  right frim the web site and putting the number in there.  You said you can get to your account  is there something that says   MyVerison2.0 login?  or veriizonwireless.com/myverizon and enter  your 10 digit cell number and password, if you do not have a password you will have to register and you will be offered different ways to  refill your cell. Hopes this helps.
    Message was edited by: Minniehaha

  • This is how to add extra Exif data to Aperture :-)

    Folks
    Often I need additional Exif data in Aperture - which is not available in the standard install.
    For example - exactly which lens did I use - not just a focal lenght - which might be any one of various lenses I have.
    Or - which focus point was used?
    The list is endless...
    If you are interested - go to this thread in dpreview
    http://forums.dpreview.com/forums/read.asp?forum=1017&message=22939488
    A neat combination of an AppleScript and ExifTool
    Go for it
    Brian

    Hi,
    I'm the "author", if you can call it that, since most of the script is, as someone earlier mentioned, Brett Gross' work. I was the one that glued exiftool to it and got it working with my Aperture setup. I am looking at the various problems that have popped up on dpreview and with personal correspondence and trying to find solutions.
    But it isn't easy. As Charles said, the Aperture dictionary isn't helpful in that regard. And with the flexibility that Aperture provides in naming is the curse here. And all the variables with versions, external edits, etc. It gets very complicated. But if you look at the thread on dpreview, someone has possibly found a way to query the SQL database to make it all work smoothly.
    It is very easy to do this stuff at import. I am just putting the finishing touches on an Automator action to import the files and add the EXIF data (it will even query GeoNames and add the city, state & country IPTC data if there is GPS data present in the file).

  • How to add dropdown in excel using java?

    First of all sorry for creating new topic... i searched for it but i couldn't get it...
    Guys do you have any idea on how to add drop down in excel using Andy Khan's JExcel API? Or is there any other way?

    Sounds like a question for Andy Khan or the JExcel forum.

  • How to add third-party libs to Java WAS for my Webdynpro DC?

    Hello all,
    Here is my scenario:
    I have some thrid-party libs(some jars) which is necessary to my Webdynpro application. It is ok to add these files in the webdynpro project's classpath. But because these jars are missing on my server, somy webdynpro app not works.
    Could anyone give me some proposal for this kind of problem? How to add these jars to the J2EE server and access them in the webdynpro project?
    Thanks and Best regards
    Deyang

    Hi Deyang,
    Also add these jars in the <b>lib</b> folder of your WebDynpro application. Open the application in the <b>Navigator mode</b> and there under the folder structure you will find the lib folder. Copy and paste these required jars in this folder as well.
    See this pic:
    <a href="http://img508.imageshack.us/img508/4614/jars9jq.jpg">Put jar files in Lib Folder</a>
    This will solve your problem.
    Regards
    Pravesh
    PS: Please consider rewarding points if helpful and solved.

Maybe you are looking for

  • Help me plz ,about pn-begda and pn-endda

    hi everyone. what do "pn-begda" and "pn-endda" means? it always EQ "18000101" and "99991231" can anyone explain it to me ? thanks very much

  • Required a Exit/Badi when creating a PO in Item Category Level

    Dear Experts,                      I want a Exit/Badi when creating a Standard Purchase Order in item Category level when i am giving item Category as L (Subcontracting) Component Over view will have the material that material should come and sit int

  • How to call webservices from IDM

    Hi, can anyone provide some documents how to call a web service from IDM 7.1 Thanks in Advance Regards, mary

  • Cannot open Shopping Cart

    Ever since I updated to iTunes for Windows version 7, I have not been able to open my shopping cart. When I click on the cart, I see the "Accessing iTunes Store..." and process bar animation in the LCD for a moment and then I get the following messag

  • Please send me a PERMANENTLY valid link to the lat...

    I don't have time to hunt around every 1-2 months for your latest version. Many people have this problem. Please make this installer easy to find on your website or allow me to choose the msi installer from your upgrade prompt window, that would be k