Gregorian Calendar class

Hi, i am new to this class and would like to know if anyone could help me. I am trying to do a bookings form and have 3 comboboxes which will hold the days, months, and a specified no. of years. I would like to know how i can use this G.C class to do so, and if there are any tutorials.
Also for these combos do i need to specify the no. of days manually or can i obtain this from the G.C class. i have looked at the api but aint sure where to start.
Any help appreciated
thanks

RTFM
GregorianCalendar cal = new GregorianCalendar();
int year = cal.get(Calendar.YEAR)

Similar Messages

  • Gregorian Calendar & Regional Settings effect

    I have a problem where the last week of the month gets cut off in my Calendar display.
    (e.g. Feb has 24 days instead of 28 yr2002)
    It occurs for all months except for March and June when the last day falls on a Sunday.
    It only happens when the Regional Settings is set as English (United Kingdom). No problem for US.
    Have used the Gregorian Calendar class. Is this a known issue?

    Do you have a sample code that shows this? Which version of java do you use?

  • Get time difference Within 2 gregorian Calendars, 1 obtained via SimpleDate

    Hi guys
    I'm having a problem with an application, i've posted something before about it and with two GregorianCalendars.
    This one is receiving a GregorianCalendar value from the default constructor, and the second gregorian calendar from a String, using SimpleDateFormat class
    The problem is that whenever i start the application it get stucked at: "Deze datum ligt: 56 in het verleden" meaning from dutch "this datum is 56 days in the past"
    the issue is thus at the method "getVerschil()" which means "get difference" in Dutch.
    Even if you try to modify the date fields from the class with the main method, inserting new dates it keeps on telling me 56.
    I was wondering if you see anything strange in the code and then a little question.
    Does the JDK sees a GregorianCalendar made with the default constructor, and a GregorianCalendar made with a SimpleDateFormat string patter "dd-mm-yyyy", in the same way?
    I mean, can java make a comparison within the 2 Calendars recognising which are days and which are the months?
    Thank you guys:
    Below the codes, the first one is the interface and below you'll see the main method class which inserts the date with SimpleDateFormat
    public class Kalender {
          * attributes
         private final String patroon;
         private String datum= null;
         private String userDagText= null;
         private int userDag;
         private int userMaand;
         private int userJaar;
         long DAGMILLIS=  24*60*60*1000;
         //deze kalender wordt gemaakt op het moment dat de toepassingen aangezet wordt
         GregorianCalendar nu= new GregorianCalendar();
         //deze kalender word gemaakt door de user-ingevoerde datum
         GregorianCalendar userCalendar= new GregorianCalendar(userDag, userMaand, userJaar);
         //datum formatter
         SimpleDateFormat sdf;
          * Constructor
         public Kalender(String datum, String patroon){
              this.patroon= patroon;
              this.datum=datum;
              sdf= new SimpleDateFormat(patroon);
         }//EOF
         public void setUserDate(){
              Date userDatum= sdf.parse(datum, new ParsePosition(0));
              userCalendar.setTime(userDatum);
              userDag= userCalendar.get(Calendar.DAY_OF_WEEK);
              userMaand= userCalendar.get(Calendar.MONTH);
              userJaar= userCalendar.get(Calendar.YEAR);
         }//EOF
          * deze methode returns de hele date
         public String geefDatum(){
              return sdf.format(userCalendar.getTime());
         }//EOF
          * deze methode bepaald of de ingevoerde datum een schrikkeljaar is
          * deze methode vindt het tijdverschil tussen twee datums
         public String getVerschil(){
              long userMillis= userCalendar.getTimeInMillis();
              long nuMillis= nu.getTimeInMillis();
              if(nuMillis==userMillis){
                   return "deze datum zijn gelijk";
              } else if(nuMillis>userMillis){//userdatum in het verleden
                   long millisVerschil= nuMillis-userMillis;
                   long dagenVerschil= millisVerschil / (DAGMILLIS);
                   return "Deze datum ligt: "+dagenVerschil+" in het verleden";
              } else  if(nuMillis<userMillis){//userdatum in het toekomst
                   long millisVerschil= userMillis- nuMillis;
                   long dagenVerschil= millisVerschil / (DAGMILLIS);
                   return "Deze datum ligt: "+dagenVerschil+" in het toekomst";
              return " ";
    }The tester (main) class which creates the second GregorianCalendar is the following
    public class KalenderTest {
         public static void main(String[] args){
              //constructor werkt
              Kalender kal= new Kalender("01-28-2010", "dd-mm-yyyy");
              //setUserDate werkt
              kal.setUserDate();
              //testen van getVerschil
              System.out.println(""+kal.getVerschil());
         }Edited by: classboy on Apr 26, 2010 9:22 PM
    Edited by: classboy on Apr 26, 2010 9:23 PM

    classboy wrote:
    Does the JDK sees a GregorianCalendar made with the default constructor, and a GregorianCalendar made with a SimpleDateFormat string patter "dd-mm-yyyy", in the same way?Of course not.
    And is there anything wrong with your code? Plenty. You passed the fields to the GregorianCalendar constructor in the wrong order. You got the day of the week and then used it as if it were the day of the month. That's just from a quick look, there's probably more.

  • Gregorian Calendar: Calendar.VARIABLE

    Hey
    Im trying to make a calendar and i have read some tutorials about Gregorian Calendar.
    Im having problems with the Calendar.VARIABLE, which can not be found, for example: Calendar.MONTH or Calendar.YEAR.
    Im getting this error:
    Calendar.java 16: Cannot find symbol
    symbol : variable MONTH
    location: class classes.Calendar
    calendar.roll(Calendar.MONTH, false); // Go back a month
    Here is the code:
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    * @author Jesper
    public class Calendar {
        public Calendar(){
            GregorianCalendar calendar = new GregorianCalendar();
            calendar.roll(Calendar.MONTH, false); // Go back a month
            System.out.println(calendar.get(Calendar.MONTH));
    }

    You are trying to access java.util.Calendar.MONTH in your Calendar class. Either you use the fully qualifyed name java.util.Calendar.MONTH or even better rename you class to MyCalendar to avoid confusion.

  • F150 dunning prog. and Gregorian calendar-wrong interest rates calculation

    Hello everyone,
    I have a problem with F150 - dunnning program and the Gregorian Calendar. I defined a interest rate indicator and I choose Gregorian calendar - 365 days in the year but SAP calculate 360 days and the interest rates are wrong u2013 to high. I have found the OSS note 82995 - Dunning program interest calc. on 360 not 365 days u2013 but as a matter of fact there is no solution which is appropriate for me because I want to print interest along with dunning letter. Maybe you had had the same problem and maybe you found solution.
    Thank for you help
    Tom

    FSKB     G/L Account Posting
    this transaction is not working

  • Issue with Gregorian Calendar and setting Day of the week

    Hi
    This may have a simple solution, but its currently got me stumped. Basically, after some calculation I determine the date that a particular event should occur on. These events are listed in a JTable where the column headers are the dates of the beginning of the weeks. In order to place my calculated event in the correct column I create a Gregorian Calendar, set it to the date of the event and then set the day of the week to the beginning of the week. Normally this works fine but for a few instances, rather than getting the date at the beginning of the week, I get the date thats the beginning of the next week.
    As a quick example, to kind of illustrate my problem:
    I determine that the date of the event is 27/06/2006 which is a Tuesday.
    I want this event to appear in the column headed 25/06/2006, the date of the beginning of the week.
    In fact it appears in the column headed the 02/07/2006 which is the beginning date of the following week.
    Is there anyway to get it so when I set the day to the first day of the week it goes to the beginning of the current week rather than the beginning of the next week?
    Any suggestions would be gratefully recieved as I'm currently struggling to think of any.
    Thanks

    Hi, I dont say Monday is the begining of the week. At least I dont think I do.
    As for code I'll post the conversion bit which is:
    for (int i = 0; i < areaNameSelectionTable.getRowCount(); i++) {
    GregorianCalendar conversionCalendar = new GregorianCalendar();
    conversionCalendar.setTime((java.util.Date) prioritiesTable.getValueAt(i, 10));
    conversionCalendar.set(GregorianCalendar.DAY_OF_WEEK, GregorianCalendar.SUNDAY);
    }//end for loopI then create a string from the GregorianCalendar in the format DD/MM/YYYY and compare that with the headers of my table columns (Also dates in the format DD/MM/YYYY) When they match thats the column this particular event should appear in. I can post this code if necessary, but I dont know if its relevant.
    Thanks

  • How to create a Calendar Class in Universe.

    I want to create a Calendar class which will further contain Year,Quarter,Month,Day,Week Objects which can be used at report level.
    In our database we have different dates in " DD/MM/YYYY:hh:min:ss " format.
    I would like to know if this can be used to create a new Calendar Object or do I need a different table in DB like Calendar look up table provided in sample efashion universe?
    Help appreciated.

    Hi,
    Sorry for the delay in coming back - I had no access yesterday.
    I am not sure what you mean. If you have a lookup table, then you create views/aliases of this table for each of the dates you want to use it for.
    So f your transaction record contains original date and paid_date
    you would create a
    original_date_view as select * from calendar_lookup
    paid_date_view as select * from calendar_lookup
    these views could then be joined to the orginal_date and paid_date fields in your transaction table.
    In the universe you would then expose 2 classes, which contained the same objects.
    Original_date
    Date,
    Day,
    Month,
    Year
    etc
    Paid_date
    Date,
    Day,
    Month,
    Year
    etc
    If you are not using the lookup then you would have to code each date object based on the transaction date field
    So Day in orignal_date would be to_char(txn.original_date, "dd")
    while Day in Paid_date would be to_char(txn.paid_date, "dd")
    Hope this helps
    Alan

  • Problem vi� Calendar class

    Hi.
    I have a class in my project that gets the current date and time using the Calendar class. But there is a little problem. The month seems to be one month late.....now it should be 6 (June) but it displays 5 as if it is May. A similar thing happens with the hour. It is always one hour ahead of the time eg. if it is 18:54 then the time says 19:54.....does someone know what the problem is????

    Read the javadocs about the java.util.Calendar and/or java.util.Date class. Months are 0-based, not 1-based, so 0==January.

  • Chinese character Display for Date from Gregorian calendar in JSP

    Hi
    I am doing internationalization for my JSPs, as part of that i am doing character encoding to utf-8(for chinese/japanese). Evrything is fine..
    Now the problm is i am displaying gregorian calendar to select date in a small window using some javascript code...
    For default encoding it is working fine....for utf-8 or other encoding it is raising error.(may be javascript)and also the date is nto displaying properly..i think the problem would be in javascript/.
    So can you pls tell me how to over come this problm...
    thanks in adance...
    regards
    bhaskar

    Sorry ..forgot to include the output...
    this is the output i am getting instead of 29-Nov-2005 00:00:00
    29-A-2005 00:00:00

  • Create a function that convert date Gregorian calendar to Hijri calendar

    hey guys, i had an assesment i need to finish as my test for flash developer vacancy...
    i need to create a function that convert date Gregorian calendar to Hijri calendar in flash
    is that possible??
    i've search through google, but still doesnt find anything useful yet..
    kinda need ur help plz.....

    http://www.codeproject.com/KB/datetime/hijrigregorianclass.aspx

  • Discussing Calendar class

    I had a quickie utility program to write for a friend of mine and seeing as how I am incredibly new to Java I came here to look for answers. Doing a search on adding to days in an object of the Calendar class, I've made a loose obersvation based on answers.
    What I needed to do for my program was to simply increment the days. The answers I found on the forum were to use Calendar.add(Calendar.DATE, 1). However, the issue I found was the month was not being incremented and since this was a quick and dirty little utility, i didn't want to have to write a whole bunch of other code to check the date in order to increment the month.
    Or am I missing something?
    A note on the program I wrote. It was a simple command line program and the first argument was the beginning date, and the second argument was the ending date in the format of "mm/dd/yy". Also keep in mind there is other processing and code, I'm only posting what I did with the object of Calender class.
    What I did with my program was the following:
    ********** Begin Code Snippet **********
    Date bdate = new Date(Date.parse(args[0]));
    Date edate = new Date(Date.parse(args[1]));
    Date cdate = new Date(Date.parse(args[0]));
    Calendar begindate = Calendar.getInstance();
    begindate.setTime(bdate);
    Calendar enddate = Calendar.getInstance();
    enddate.setTime(edate);
    Calendar currdate = Calendar.getInstance();
    currdate.setTime(cdate); // currdate was init to begin date and will be the variable incremented
    /* other processing goes here */
    numdays = enddate.get(Calendar.DAY_OF_YEAR) - begindate.get(Calendar.DAY_OF_YEAR);     
    for (int i = 0; i <= numdays; i++)
         currdate.add(Calendar.DAY_OF_YEAR, 1);
         month = currdate.get(Calendar.MONTH) + 1;
         day = currdate.get(Calendar.DAY_OF_MONTH);
         year = currdate.get(Calendar.YEAR);
         dateString = month + "/" + day + "/" + year;
         System.out.println(dateString);
    ********** End Code Snippet **********
    Now, this works in that when I print out the dateString, the month is incremented and the day of the month gets reset to the first day when a new month is started.
    The purpose of this post is to discuss why this is wrong. Now, for the purposes of the little utility program I wrote, this is more than sufficient because all dates concerned were within the same year. (07/09/01 to 12/31/01 to be exact.)
    However, I decided to play around with this and enter dates that would span the New Year. This did not work because the variable "numdays" ends up being in the negative and the for loop does not process properly.
    Other than that issue, why is it wrong to increment the Calendar.DAY_OF_YEAR? Why is it recommended that the Calendar.DATE field is incremented? And what other processing must be done to get the month to roll over into the next month when the date changes from the 30th (or 31st or 28th, or 29th for leap years) to the 1st?
    -- Jayne

    Hi !
    Just wanted to say few things. First Calendar class's add method is an abstract method
    only (check API specification). Which means its not a concrete method and does NOTHING. You should instead use GregorianCalendar's add method . Secondly months and years do get incremented. You have to be careful because months start from 0 to 11 and not from 1 to 12.
    Here is a piece of code(a method) that adds 7 days to a dateString, you can try out :
         public void getDate(String dateStr)
              GregorianCalendar dateNextWeek = new GregorianCalendar();
              SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");     
              try {
                   dateNextWeek.setTime(formatter.parse(dateStr));          
              } catch (Exception ex) {
                   ex.printStackTrace();
              int day = dateNextWeek.get(Calendar.DAY_OF_MONTH);          
              dateNextWeek.add(Calendar.DATE, 7); //adds 7 days
              System.out.println("day = "
    + dateNextWeek.get(Calendar.DAY_OF_MONTH));
    //month begins from 0
              System.out.println("Month = " + dateNextWeek.get(Calendar.MONTH) + 1);
              System.out.println("Year = " + dateNextWeek.get(Calendar.YEAR));                    
    Hope it helps u !
    regards
    Prasanna

  • Islamic and Gregorian Calendar

    Hi all
    I have a task in which I have to convert Gregorian Calendar to Islamic Calendar and vise versa. Can somebody help
    Sajid

    Hi!
    Plz describe ur problem in details

  • Problem with Calendar Class... Help please

    I have a simple program that use a Calendar class to know the week of year from a Date.
    Calendar cal = Calendar.getInstance();
    cal.set(2001,5,15);
    cal.setFirstDayOfWeek(Calendar.MONDAY);
    cal.setMinimalDaysInFirstWeek(7);
    System.out.println("week of year = "+cal.get(Calendar.WEEK_OF_YEAR));
    The problem is that in Windows OS the program work good but when I run the program on UNIX
    week_of year show Zero. The same for DAY_OF_YEAR and WEEK_OF_MONTH

    So the difference is actually the Java version, not the operating system, right? I'm not surprised that a version as old as 1.1.3 has bugs in Calendar. Upgrade.

  • I am using Calendar class, and want to see if a date is older then 24 hours

    i have a Calendar class instance, and i want to test if the current date & time is older then 24 hours. i have been playing with for 2 hours. anyone know how to do this?

    One way is to call .getTime().getTime() (yes, that's 2 of 'em) on the Calendar object, which converts the Calendar's time to a milliseconds value which can be compared to System.currentTimeMillis()
    The two times are within 24 h of each other if the ms values differ by less than 86 400 000.

  • Using Calendar class

    Hi all,
    can anybody help me for developing a program using Calendar class.what i am trying to do is
    I have javascript calendar file. daily working hours in perticular project (user give input).
    when i am selecting whole week days can i get total of weekly working hours and total in the next page or same page.
    please help me. I am strucking here
    thanks&regards
    Vijaya

    Do you want a Java program, or a JavaScript program. Java != JavaScript

Maybe you are looking for

  • COPY function on a Multiprovider - - Not saving data

    Hi, Im facing a wierd problem. Im tryin to run the COPY function on a Multiprovider. I've selected 2 fields as 'To be Changed' : 0INFOPROV and 0VTYPE. and 1 KF (ZACCINS) to be copied. I tried to run the PF through a Planning Sequence in 'Execute with

  • Failed to parse SQL Expression Field

    Hi, I design a report with an SQLExpressionField.  When I change datasource at runtime:                 reportClientDoc.getDatabaseController().setTableLocation(table, tableNew); I got this error: ERROR com.businessobjects.reports.sdk.JRCCommunicatio

  • Can you embed a jar into a webpage?

    Hi, I worked out how to embed my .class file into a webpage with <applet>. Im using netbeans which also creates a jar which includes my audio files in the archive. Could I just upload the jar file and embed that into a webpage?

  • Struts configuration

    Does anyone have experience using Struts 1.1 with oc4j. I have successfully created an application, but I am having problems defining my ApplicationResources in the struts-config.xml. Everything works fine if I define them in the web.xml, but when I

  • Where's the class files? Why the "installer" nonsense?

    Why do I have to download a big fat Windows installer executable just to get the 1.4.2 classes? I don't have admin access to my office PC and simply want to import the newer classes into my JBuilder projects. Why all the hoops and unwanted extras?