I use JodaTime to deduct a day from current date . But it dosen't work for me, which means, my Date remains same, nothing is deducted! .
Here is the code ,
public class Note {
private java.sql.Date date;
public java.sql.Date getDate() {
return date;
}
public void setDate(java.sql.Date date) {
this.date = date;
}
}
Note notez=new Note();
notez.setDate(new java.sql.Date(new DateTime(new Date()).minus(1).toDate().getTime()));
Have any ideas about this .
Thank you.
DateTime.minus(long) will deduct the amount of milliseconds passed to the method.
What you're looking for is DateTime.minusDays(int)
Check the Javadoc
Try this:
notez.setDate(new java.sql.Date(new DateTime(new Date()).minusDays(1).toDate().getTime()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With