File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
dates in java
Joined: Mar 12, 2001
Mar 12, 2001 22:47:00
How to get previous days date in
. i.e. current date-1
Joined: Mar 09, 2000
Mar 13, 2001 07:25:00
I use the Calendar class as all familiar Date Constructor/methods are deprecated.
Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.DAY_OF_MONTH, -1); // or rightNow.add(Calendar.DATE,-1);
This backs up the calendar one day.
The Java 2 API docs are pretty good in showing how to use this class.
Hope this helped.
by "code" tags.
Senthil B Kumar
Joined: Feb 09, 2004
Jun 23, 2004 03:23:00
public class Prev
public static void main(
Calendar xx = Calendar.getInstance();
Date dt = null;
dt = xx.getTime();
System.out.println("Yesterday Is : " + dt.getDate());
Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside Here
I agree. Here's the link:
subject: dates in java
Finding Dates from Local System
date problem in linux
how to covert string to date object?.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015