A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
Java in General
Today(Yes), Tomorrow(No), Date realated problem.
Joined: Jul 29, 2004
Aug 03, 2004 09:03:00
If only someone could help
All code(s) below gives me a current date,
but I also need to get tomorrows and yesterdays dates.
I think I can�t use simpledateformat because I need to import import java.sql.*;
So if anyone can tell me how to modify some of the codes below, It would be great. All I need is that I get forexample this yesterdays or tomorrows date with the
these are the codes what I have try to use without success
java.sql.Date date = new java.sql.Date((new GregorianCalendar()).getTime().getTime()); jTextField2.setText(""+date);
Calendar cal = GregorianCalendar.getInstance(); DateFormat fmt = DateFormat.getInstance(); String buf = fmt.format(cal.getTime()); jTextField2.setText(""+buf);
java.util.Date today = new java.util.Date(); java.sql.Date sqlToday = new java.sql.Date(today.getTime()+1); jTextField2.setText(""+sqlToday);
Joined: Oct 17, 2001
Aug 03, 2004 09:15:00
I think it will point you in the right directions.
I agree. Here's the link:
subject: Today(Yes), Tomorrow(No), Date realated problem.
conversion of string into java.sql.Date
Variable type question?
inserting a date field
JSP and SQL problem
util.Date to sql.Date
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014