Gregorian calendar question

Hello,
I'm having some trouble understanding the date format method, in particular, how to institute the LONG, SHORT variables of a date output.
Could somebody possibly explain where to use it? I've check the api and I just couldn't grasp it fully from that.
thank you

No you don't sound demanding. It's always good to ask.
Because SimpleDateFormat formats a Date instance. So you need a Date instance for it.
You have a Calendar instance. Which is good because it's the right thing to be using when you want to add days like that. But a Calendar is not a Date so you can't use the Calendar in the formatter. You have to get the Date instance that represents the date in the Calendar instance.
And convienently there is a method called getTime that returns a Date instance from Calendar.
To be honest when I was going to help you out at first I wrote it (and you can) as
System.out.println("You will be 1,000 days old on: " + outCome.format(helpMe.getTime()));But then I thought better of it since that's more confusing. It's the same code as what I gave you but crammed onto one line.
And thanks for using the code tags. Appreciated. :)

Similar Messages

  • 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.

  • 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

  • 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

  • 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

  • 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.

  • 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?

  • Calendar question(s)

    APEX 3.01, RDBMS 10GR2
    I am new to the APEX tool. Two calendar questions, please.
    (1) I have a requirement that the values in the calendar object ("year" drop box) need to go back to 1800. Currently, when selecting on the calendar object, the earliest year available is 1920. Any ideas on how to expand the range of "year" dates to allow the user to select as far back as 1800?
    (2) My requirement calls for limiting users to selecting the calendar object for populating the date field. Currently, while users have the calendar available to populate a date field, they are not forced to use it - ie. they could fill in the date field with a valid date and not use the calendar. Is there a way to limit user input of date fields to use the calendar object only?
    Thanks in advance,
    Barry D.

    Chrissy,
    Thanks for the suggestion on how to force the user to use the calendar instead of entering data directly into the date field box. While setting the HTLM Form Element Attribute to "disabled" works for entering a new date [user cannot input directly into field, must use calendar], however, when I save my record, the date field is not saved to the database. All other elements are saved to the database. The saving of all data elements including the date, was working prior to this change. When I removed the suggested element attribute from my field and save a new record, all data is saved.
    Any suggestions?
    Thanks in advance.
    Barry D.

  • Gregorian Calendar - Week 53 not displayed

    Hello all,
    My question is really quick : I'm displaying a DateNavigator in a Webdynpro Iview and the week 53 is missing.... how can I display it?
    I changed the Location values :
    - the default location is en_US
    - the location in parameter is FRENCH
    I tried to modify the location but nothing append. I'd like to switch between US configuration and FRANCE configuration to see the differences but for now I only have the US configuration (Sunday as the 1st day of week)
    I'll give you a part of my code, maybe you will see what's wrong in it :
    public static void wdDoModifyView(IPrivateVCalendar wdThis, IPrivateVCalendar.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
              if (firstTime) {
                   IWDDateNavigator myCalendar = (IWDDateNavigator) view.getElement("DateNavigator");
                   myCalendar.mappingOfOnWeekSelect().addSourceMapping("year", "year");
                   myCalendar.mappingOfOnWeekSelect().addSourceMapping("week", "week");
                   myCalendar.mappingOfOnDaySelect().addSourceMapping("day", "day");
                   GregorianCalendar myDate = new GregorianCalendar(Locale.GERMANY);
                   myDate.setTimeInMillis(System.currentTimeMillis());
                   wdThis.updateDatesCalendar(myDate.get(Calendar.YEAR), myDate.get(Calendar.WEEK_OF_YEAR));
        //@@end
    Thank you for your help.
    Regards

    Hi Rajesh,
    The occurence of a 53rd week is internationally standardized. The check in BW follows these international conventions which count the week depending on the majority of days:
    - if the week has 4 days of the old year it counts as CW53;
    - if it has 4 days of the new year it is CW1.
    That is to say, the number of ISO weeks belonging to a year number is equal to the number of Thursdays in the correspondingly-numbered calendar year, and is equal to the week number of December 31st; and a year has 53 weeks if, and only if, the following day is in its Week 53.
    The 53-week years in the range 2000-2027 are: 2004, 2009, 2015, 2020, 2026.
    That pattern repeats every 28 years before 2100.
    For 0CALWEEK, it will calculate the week based on the calendar you specified in tcode RSRHIERARCHYVIRT. Please note that RSRHIERARCHYVIRT is a BW global setting, i.e. that means the system will use this calendar for all data targets.
    If you have some special business impact to include a 201153, please check the following:
    1. write a routine in the transfer rules for 0CALWEEK that modifies into the week 201201.
    2. manually correct the data in the PSA and load from PSA into the target cube.
    Rgds,
    Colum

  • Calendar questions

    I've just been to an O2 store to have a play around with the iphone, it looked great and seemed to work as good as I expected it to. A couple of questions though, can the events in the calendar be colour co-ordinated like in ical (i.e. blue for personal, green for work) and is there a week view (I only noticed list, day or month). Also, can you only play videos purchased through iTunes?
    Finally, did anyone else notice the demo iphones were the 4GB model?
    Damien

    Hi
    i dont know about the UK version but the US version - the calendar is not color coded - but is a button for Today, List mode, Day and Month - in day and month mode there are arrows to scroll back and forth and a + button to add events
    as to iTunes - you dont have to buy music from iTunes - you can load parts of or entire cd's to it and then download them to the phone (dont know if that works for videi) - there are also in the iTunes store a lot of free Podcasts you can download and then sync to your phone
    in software version 1.1.1 you couldnt make ringtones out of anything but music you bought in iTunes - on this forum folks are saying that in 1.1.2 (which is what comes on the UK version) you can now make ringtones out your own music and load them to iTunes which would then download to your phone next time you synced it ( if you turn on the option to sync ringtones)1.1.2 hasn't been released in the US so i cant verify that
    Itunes lets you synch everything or you can selectively sync certain categories

  • IPhone 2G Calendar question, PLEASE.

    All I see for the calendar here is about syncing. But I have no problems with that.
    My problem is that my Calendar goes from Sunday to Saturday and I'm very used to calendars that go from Monday to Sunday.
    Is there ANY possibility to change it?? I posted this on several online question sites and no one knew and I don't see it here either. Is there a possibility??
    Thanks a bunch.

    This is determined on your iPhone at Settings > General > International > Region Format.
    You must select a Region Format with a default calendar that goes from Monday to Sunday.

  • E90 calendar questions

    Hi everyone.
    As a beginner at using the E90 calendar, I have some basic questions:
    #1 On a repeated event, if I want to change only one date of the events without moving the repeated ones, is it possible?
    #2 Is it possible to assign a repeat on a to-do entry?
    Thank You
    Jorge Teixeira

    no to both from/on the phone
    Wishing u a great time with your device,
    eseriesaddict
    Chennai
    India.

Maybe you are looking for

  • XML Gallery won't work remotely - Action Script issues

    I created an XML scrolling thumbnail gallery using a tutorial found here I then had to alter the action script to get my thumbnails to display properly -- they were spaced out or overlapping each other and not in the sequence specified in the XML fil

  • MPS & MRP

    As i understand, MPS is single item, single level planning generally done for expensive items. we have md03 also in mrp for single item single level. then wht is the difference between two? thanks in advance.

  • Cannot install photoshop elements on XP

    when I launch the autoexec of photoshop elements, i got the initial screen with the possibile options. When clicking on the "install photoshop elements", nothing happen but a window open of Window installer that provides explanation about all the par

  • Local machine using - expecting remote machine

    Any advice on this one? I did modify the security / firewall to except IChat 2009-01-04 19:42:44 -0600: No data has been received for the last 10 seconds. Audio channel info: local machine using 10.0.1.200:16402, expecting remote machine to send to 6

  • Quicktime fails to open, crashes finder / safari

    Hi all I am wondering if any geniuses can help me. I recently uninstalled quicktime (drag to trash and empty) to upgrade to the new version. It installed fine but won't work at all. If I click on any video type (avi. mov. mpg etc) it crashes. Similar