Gregorian Calender help

Hi guys and girls.
I’m a bit of a newbie and I hope I haven’t posted in the wrong thread but I need a little help. I am trying to mess about with Greg calendar. I have been told to make a diary app and was hoping to use this as not to clog everything up with strings, that and we need to implement the deletion of past appointments and stop overlapping so I need calendar. Only problem is we haven’t learnt it yet and I'm ripping out what little help I have. If I post some code can someone at least tell me why it’s on about a return statement? I know this code runs with strings but not with this int business. The other thing is where I declare what the year month day date and so forth. If I swap these variables round can I get the date to display differently? Cheers peeps the code is below.

The overall aim of this is to use a readkeybored method to take each variable and make a date for an appointment but I think thats just gonna blow me away. I have done all this and the application with strings but i really want to be a show pony and try somthing that makes sense.

Hi Ezzaral.
I have looked through it but it just seems to me that its all setting timezone and locale. Like i said I promis your not doing my homework as iv finished my assignment with strings but i just want it to be functional aswell as just finished.
Ignor the getmonth method. Still it wont comply. This is how i declared the variables for my strings but it wont work for the calendar.

You don't need to have all of the separate variables in your program to use the GregorianCalendar. It encapsulates all of that in itself. You use it by setting the fields as needed, adding or subtracting various time increments, comparing different Calendar (date) instances, etc. Perhaps these examples will help a bit more:http://www.exampledepot.com/egs/java.util/GetDateFromCalendar.html?l=rel

Working with the calendar can be a bit non-intuitive at first, as you probably see by now. Take the time to read through the API document for it, the methods available on it, and the tutorials you can find.

(Edit: I was referring to the original code you posted when I wrote this. Not the code above that you added in the mean time :) )

Mr Ezzaral you a star person for helping me at half past 10 in the evening. you say messing woth time incaments. What if i just wanted the times blank and the user fill them in when they run the readkeybord. Ie asking them for each variable to be stored infile. Is that possible? as you can see from my string class I just want it to make strings redundent so i can call one "date" instead of hundreds of strings.

You would use the inputs to construct a GregorianCalendar instance that represents the date and time they entered. Keep in mind, you would still have to write that info into your file and if comparing to another appointment, read the info from file to construct the Calendar instance that represents the other appointment.

Hey all. I regret to inform that me and greg the calendar application fell out last night and are now not speaking untill my lecturer rectifies our hatred for eachother. I am going to try and write it with date and time just to see if i can do that thing with removing old appointments. and stuff. Thanks for your help dude but i think i ned more teaching :D

hey guys. New issue, been working like a crazy man recently. I have statrted woth my greg code and have got this far. Im getting a constructor error and i think iv lost my head. the variables have been converted from string to int and the application was working but returning null on the printout method. cousdl you take a look at my code and rip it to shreds with constructive critasism. Be gentle this thing is killing me :)

Sorry dude i fixed that. The constructor at the bottom of the readkeybored was looking for sting vars not ints. fixed like a dude now. Secondly. My application calls a printout method that you can allso see at the bottom, when the print happens I get the printout
"java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=29,MONTH=3,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=985,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=0,HOUR=9,HOUR_OF_DAY=9,MINUTE=0,SECOND=0,MILLISECOND=?,ZONE_OFFSET=?,DST_OFFSET=?]"

Is there anyway to print the contence of the calander after it was made. nearly there guys

Hey dude please dont shout but i gave up with greg. Stuck to the basics but oneday i will return to you Ezzaral with the best damn diary application you have ever seen :). Seriously though cheers for the help it was a good experiance and i acctually learned alot in the process of digging around in the api and countless websites. Keep you eyes open as iv just posted again.

im sort of continuing where Jezeral stopped - were in the same class here at uni.

I was wondering how the data generated by gregoriancalender is used.

Assuming i have a reasonably similar solution to Jez - well same basic idea - create an instance of gregorian to store time and date data for appointments, and iv got the thing displaying the time in readable format (im writing this at the moment!), how would i go about writing this time and date related data into a file and loading it back into the system?

I can do basic save/load methods fine but im not sure how to handle gregoriancalender data in these cases.

im sort of continuing where Jezeral stopped - were in the same class here at uni.

Assuming i have a reasonably similar solution to Jez and iv got the thing displaying the time in readable format (im writing this at the moment!), how would i go about writing this time and date related data into a file and loading it back into the system?

I can do basic save/load methods fine but im not sure how to handle gregoriancalender data in these cases.

many thanks in advance,
Al

SimpleDateFormat has methods to format a date to a string and to parse a string to a date. If you are using a particular format, you can format the date before you write it into the file and parse it when you read it back out.