| Author |
calendar dates
|
lusha tak
Ranch Hand
Joined: Dec 30, 2000
Posts: 185
|
|
Hello all!! how is everybody doing?? hey, i have a query regarding calendar dates. is there any way to gat caendar dates for the previous week/previous month using java.util package(i.e. if today it is 19/02/2002,how do we get exactly a week's prior date 12/02/2002 )? thanks in advance lusha
|
 |
Arun Boraiah
Ranch Hand
Joined: Nov 28, 2001
Posts: 233
|
|
Hi, import java.sql.Timestamp class below line of code will take current time in millisecond and sub one week time in millisecond. this will give a time sttamp object which now will be one week old date. Which you can use Timestamp ts=new Timestamp( System.currentTimeMillis() - (24*60*60*7*1000)); System.out.println(ts); try for month (need to take care of varing no of days of month) -arun [ February 19, 2002: Message edited by: Arun Boraiah ]
|
Sharing is learning
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
|
Moving this from Servlets -> Java In General (Beginners)
|
 |
Senthil B Kumar
Ranch Hand
Joined: Feb 09, 2004
Posts: 140
|
|
import java.util.Date; import java.util.Calendar; public class Prev { public static void main(String args[]) { Calendar xx = Calendar.getInstance(); Date dt = null; xx.add(Calendar.DATE,-1); dt = xx.getTime(); System.out.println("Yesterday Is : " + dt.getDate()); } here replace -1 with -7 to get prev weeks calendar dates...
|
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 WEBlog
|
 |
 |
|
|
subject: calendar dates
|
|
|