Link to home
Start Free TrialLog in
Avatar of jedistar
jedistarFlag for Singapore

asked on

Gregorian Calender Year

Hi,

Everytime i get a my gregcalendar.year it comes up as '6'
How do i make it show the full year.. i.e 2006 or 1999
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You need to use a DateFormat with yyyy
Avatar of jedistar

ASKER

example?
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Let me rephrase my question.. i wish to compare a date in gregorian format
to a date in my db which is in varchar format.

how do i do this

(points up to 400)
using select sql
Please show how your varchar dates look
30/1/6

30th jan 2006
DateFormat df = new SimpleDateFormat("MM/d/y");
java.util.Date fromDb = df.parse(resultSet.getString("DateCol"));
boolean dbLater = fromDb.after(otherDate);
following shows you how to parse a date

http://javaalmanac.com/egs/java.text/ParseDate.html?l=rel

you could also use a PreparedStatement and do the comparison directly in the query
that would save you havin g to bother with parsing altogether
How do i compare if a gregoraion date is equal to another greg date?

How do i convert a greg date to the above MM/D/Y
boolean equalDates = date1.equals(date2);
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)