File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Date convert help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date convert help" Watch "Date convert help" New topic

Date convert help

Loges waran

Joined: Feb 21, 2012
Posts: 9
Hi code ranch,

I need to get one logic.

For example, I have one Date 03-30-2012. My period is 10 days.

I need to subtract the number 10(Dynamic values may change) from 03-30-2012... The result should be 03-20-2012.

Can anybody help me for fixing this bug.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
What bug? You showed no code for a bug.

Did you look at the Date object? It has methods to get the date and its parts.

Loges waran

Joined: Feb 21, 2012
Posts: 9
Hereer is the code:

var notifperiod = a.value;
var expirydate = b.value);
var notifdate = new Date(b.value);
var date1=notifdate.getDate();

var notifdatefinal = (notifdate.getMonth()+1)+"-"+notifdate.getDate()+"-"+notifdate.getYear();


In this code, when i enter April 5 as Expiry date and notification period as 10 days. it shows the result of 02-25-2012 It is not showing 03-25-2012.
But for if the difference between Expiry date & notif period occurs in the same month means its working fine.

Suggest me to solve this problem.
I agree. Here's the link:
subject: Date convert help
It's not a secret anymore!