Date Manipulation in JAVA

I had an requirement on date manipulation in Java and i had a very hard time searching on google. Finally i came to know on how to manipulate dates in Java and with this article i will be showing code snippets on the same. This code snippets is applicable in Core Java, JSP and Servlet Pages.

Formatting Dates:

Adding Days to Current Date:


Adding Month to Current Date:

Adding Year to Current Date:


Subtracting Year to Current Date:


Subtracting Month to Current Date:

Subtracting Day to Current Date:

Adding Hours to Current Date:

Adding Minutes to Current Date:

Adding Seconds to Current Date:

Subtracting Hours to Current Date:

Subtracting Minutes to Current Date:


Subtracting Seconds to Current Date:

Tagged . Bookmark the permalink.

12 Responses to Date Manipulation in JAVA

  1. Revathi says:

    It’s really gud & useful , Thanks for giving a clear information abt Date function

    Thanks,
    Revathi

  2. Rohit says:

    Its really help me a lot
    Thax.

  3. mint says:

    thanks. . this is a clear and good explanation

  4. Stian says:

    This really just goes to show how many code lines one has to write to do simple date manipulation in Java. There certainly is room for improvements in the Java language in this area.

    Good article.

  5. bynot says:

    how to implement Date manipulation without importing simple Date Format?? i need a code..pls reply asap.

  6. ISMAIL says:

    thanks alot. It works nicely

  7. saran says:

    thanks a lot.
    I need the java code of adding 5 days of current date excluding sundays. That means if the 5 days contains sunday it will skip that day and add next day

  8. Anup says:

    dis is wat i was lukin for….working perfectly fine :)
    very good article..!!

  9. rami says:

    eh my friends i have a proposition for manipulate a date in jsp/servlet you must simply to utilise the taglib fromat predefini in jsp/jstl search in sun.java it’s very simple and good chance

  10. anu says:

    hi,
    i would like to get the complete source in java for navigational calender with current date indicator.

Leave a Reply