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
jedistarAsked:
Who is Participating?
 
objectsCommented:
> How do i compare if a gregoraion date is equal to another greg date?

http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html#equals(java.lang.Object)

> How do i convert a greg date to the above MM/D/Y

See the link I posted above for examples of formatting dates
You can get the Date instance from the Calendar using its getTime() method

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#getTime()
0
 
CEHJCommented:
You need to use a DateFormat with yyyy
0
 
jedistarAuthor Commented:
example?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
CEHJCommented:
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
System.out.println(df.format(cal.getTime()));
0
 
jedistarAuthor Commented:
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)
0
 
jedistarAuthor Commented:
using select sql
0
 
CEHJCommented:
Please show how your varchar dates look
0
 
jedistarAuthor Commented:
30/1/6

30th jan 2006
0
 
CEHJCommented:
DateFormat df = new SimpleDateFormat("MM/d/y");
java.util.Date fromDb = df.parse(resultSet.getString("DateCol"));
boolean dbLater = fromDb.after(otherDate);
0
 
objectsCommented:
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
0
 
jedistarAuthor Commented:
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
0
 
CEHJCommented:
boolean equalDates = date1.equals(date2);
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.