Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Cool How to create a Calendar

    Hi, I have implemented a program and a calendar is part of my app. To implement the calendar I have got it's source code from the Internet. I want if user clicks on one day of the calendar then another page will be shown to the user and in that page user will enter a specific number and then the user will click on a save button in it and after that when user selects that day in the calendar again it must show a page with just the specific number which the user enterd earlier!to implement this I want to create indexes for all the days of a year which are like a specific key for each day and I want to save the indexes in the database so when user clicks on a day with a specific key it shows it's specific number! Could anyone tell me how can I create indexes for all days of a year?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    What is the index you want? An integer? The day of the year?

  3. #3
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    thanks for your reply, I want each day of a specific year has an Integer index. for example last day of the third month of a year has Index 92.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Is that the day of the year? An integer from 1 to 365/366.

  5. #5
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    thank you for your reply, Yes I mean this!

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    The Calendar class will give you the day of year for a given date.
    Have you read the API doc for that class?

  7. #7
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Exclamation Re: How to create a Calendar

    I knew it, but first I want to create indexes for all the days and the I want to use the index for selected day like I explained earlier!

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Sorry, I don't understand your problem.
    The indexes are just the numbers 1-365. What is there to create?
    Is the problem going from the nth day of the year to the month and day of month?

  9. #9
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    I don't know how to extract the days of a year and then create indexes for them?! Is it clear for you

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Have you looked at the Calendar class? I has method for doing a lot date manipulations.
    You can create the DD/MM for any day of the year with its methods.

  11. #11
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    How can I create the DD/MM for any day of the year for the Calendar?what is its methods? In Java apI doc I found I can use
    int get(int field)
    Gets the value for a given time field.
    and

    DAY_OF_YEAR
    Field number for get and set indicating the day number within the current year
    but I don't know How can I use these two things to extract the days of a year and create indexes for the days!?

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Look at the large code sample in the API doc for using the methods to get and set dates.
    If you set the day of the year starting at 1 get the date for that day, and continue through day 365 you will have the dates for the 365 days of the year.

  13. #13
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    thanks, when I write this code in my prog calendar.get(calendar.DAY_OF_YEAR) the prog will have an error that is can not find symbol DAY_OF_YEAR. so what is your solution about it?

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Look at the API doc to get the correct spelling.

    I copied the large example from there and had no problems compiling and executing it.

  15. #15
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    I have copied the code from the API but it seems my netbeans has problem for this! I can use calendar.get(calendar.DAY_OF_MONTH) instead of YEAR but if so I can't have my favorit program!

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    Did you check your spelling?
    Try this copied from the API doc:
    System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));

  17. #17
    TacoManStan is offline Member
    Join Date
    Sep 2011
    Posts
    50
    Rep Power
    0

    Default Re: How to create a Calendar

    Just a thought... If you are using the Calendar class, I hear the the GregorianCalendar has better methods and is more internationally friendly. I have never used the 2 myself so I don't know the difference.

  18. #18
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    Hi, I have a problem again, about the Calendar How can I differ between selected date and date of today? I want that if user selects a date in Calendar which is less than date of today, some thing being shown to the user!

  19. #19
    elenora is offline Member
    Join Date
    Apr 2011
    Posts
    30
    Rep Power
    0

    Default Re: How to create a Calendar

    How can I differ between last day of a month and first day of the next month?

  20. #20
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: How to create a Calendar

    The Calendar class has many methods. Is there one that will compare two dates?

Page 1 of 2 12 LastLast

Similar Threads

  1. Create new Calendar object???
    By aliencc in forum New To Java
    Replies: 4
    Last Post: 01-17-2011, 01:19 PM
  2. How to add a calendar????
    By zifis in forum New To Java
    Replies: 5
    Last Post: 04-07-2009, 04:04 PM
  3. Calendar bug?
    By Stigvig in forum Advanced Java
    Replies: 14
    Last Post: 02-08-2009, 09:56 AM
  4. Create Calendar with Java
    By neoseeker191 in forum New To Java
    Replies: 4
    Last Post: 10-17-2008, 05:41 AM
  5. Web calendar
    By Daniel in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 06-27-2007, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •