date 2 « Calendar « Java Data Type Q&A

1. Date randomness and the Calendar object

You're correct Kaj, sdf is a SimpleDateFormat and in fact I'm using a shared static instance amongst threads. Do you think this could cause the kind of behaviour I'm seeing? I hadn't spotted until you posted it that I'm not actually logging the result of the call to sdf.parse(..), I just assumed that it was using the correct value.

2. Date vs. Calendar Size

Hi, Suppose you to save this object ( Date or Calendar )to any database ( ie, Object Oriented DB like Ozone , DB4O ) you can use long data type for saving and use Calendar object for runtime is prefereed because it is more usefull to you compare to Date class but compare with size Date is lesser than Calendar. Lets ...

4. Calculating difference between Calendar dates, wrong date

Hi, Why these dates are diifferent on my computer? Date d1 = Calendar.getInstance().getTime(); Date d3 = GregorianCalendar.getInstance().getTime(); d1.toString() is not the same as d3.toString().... d1 is wrong..... but I must use Calendar... - the API of some module provide me a Calendar date to caltulate the difference with the current date... d1 would be current date and it should be Calendar ...

5. Calculating dates using Calendar

Sorry, I've never worked with J2ME before and I didn't expect that the add() method is absent in its Calendar API. In this case get the time in millis, add 5 days (in millis) to it and set the time in millis back. But this way isn't reliable as it doesn't take the daytime savings in account. Try asking in J2ME ...

6. Want to diplay the date if we click a calendar icon.

Hi, Iam new to this field. Iam developing a application in which i planned to keep one calendar icon and if i click that, a calendar should be displayed and if i click any particular date, that particular date should be displayed in a text box. Please provide me solution for this problem. Thanks in advance.

7. Writing Code using Calendar and Date classes

Your birthday is June 9, 1977 You were born on a Thursday! Today is February 8, 2007, so your birthday was about 936,278,979 seconds ago, which is 10,836 days ago (or 29 years and 243 days ago). Your next birthday is 121 days from now, on a Saturday. On your birthday, you will be 30 years old. I need to write ...

8. Java Calendar set date behaviors different on JDK1.4 and JDK1.5

Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2006); c.set(Calendar.MONTH, 6); c.set(Calendar.DATE, 0); c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE)); In JDK1.4, I get the date back as 6/30/2006, but in JDK1.5, I get the date back as 7/30/2006. If I put a call like c.get(Calendar.MONTH) in between c.set(Calendar.MONTH, 6); and c.set(Calendar.DATE, 0); Then, same result (6/30/2006) print out in both JDK1.4 and JDK1.5.

9. Question on Dates and Calendar

10. Date & Calendar API

Depending on the requirement (as already discussed), you can also try setting the day of the week: cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); From the Calendar Javadoc: --- Calendar Fields Resolution When computing a date and time from the calendar fields, there may be insufficient information for the computation (such as only year and month with no day of month), or there may be inconsistent ...

11. Date and Calendar

I am trying to get the real date (and time), but I get 2 hours earlier than the real time, and if I format it to IST I get 3 hours later. My code is: DateFormat dateFormat = new SimpleDateFormat ("dd_MM_yy__HH_mm_ss"); Date date = new Date(); Calendar cal; cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("IST")); dateFormat.setCalendar(cal); return dateFormat.format(date); With the above code I get ...

12. Julian Date to Calendar Date