Convert Date Object to Calendar object

Hi,
I have a Date field in my webdynpro application, I need to to read this from my current context and convert the same to a Calendar field and pass it to my model.
Calendar date = CalendarConverter.parseDate(req_date.toString());
The above code gives me a null pointer exception.
Can anyone suggest me the right way of converting a Date object to Calendar object?
Ashwini.

Ashwini,
try to use the following code snippet:
// get calendar and set your date object
Calendar c = Calendar.getInstance();
c.setTime( <YOUR_DATE_OBJECT> );
// to manipulate the fields use this
c.set(Calendar.MONTH, 1);
// to manipulate retrieve a fields use this
c.get(Calendar.MONTH);
Hope that helps you.
Sebastian Voss

Similar Messages

  • Problems with converting date in one calendar into another.

    I am trying to convert, say, today's date into a Hebrew or Japanese calendar and put it into a form so it can be printed. I can convert date components but I can't get it so that I can use it with NSDateFormatter to print the date - it comes out as a Gregorian date even though printed from an NSDate object derived from a Hebrew calendar object.
    Is there any sample code I can look at?

    I have a compaq 3900 which I sync with ical. I use PocketmacPro.
    It is the smoothest sync give it a try.
    Isync all my callendars, contacts, transfer word and excell docs.
    There tech support is good to

  • Convert a calendar object to a date object

    hi all...i use a calendar to select date and i want to convert the Calendar object returned to a date object ..how could i do that ?? i use the following lines of code but the Date object returned is not correct ..i mean it's not the one i chose from the calendar
    Date selectedDate=new Date();
    selectedDate=(calendar1.getTime());
    Any one could help....thank you

    Show us the code where you set the calendar to your desired value. Calendar1.getTime()
    should return the relevant date.

  • Printing Date with Calendar Object

    I am trying to print the current date of a calender object in a mm/dd/yyyy format.
    When I call system.out.println(now.getInstance()); and scroll through the console, it shows DAY_OF_MONTH=29, YEAR=2006, MONTH=6 for July 29, 2006. I realize months are zero based, so month is really 7. My question is, why does:
    System.out.println(now.MONTH + " " + now.DAY_OF_MONTH + " " + now.YEAR);
    print 2 5 1.
    Logic tells me it should print 6 29 2006.
    I have searched previous posts, and couldn't find one that answers my question. How do I take a Calendar object and print its current set date?

    My question is, why does:My question is: why do you care how a Calendar stores its data? If you want to print it, get a Date instance from it and run it through a SimpleDateFormat to get a String representation of the date.
    Don't mix up data and presentation.
    And to answer your question: you don't print the Calendar's date attributes, but the values of some static constants.

  • Date change problem in Calendar object

    Hi i have a calendar object for date representation.
    When i need to go ahead a day i use a add method that adds a day to the Calendar object, and if the date is out of range it adjustes proerly to the next montha and proper date in that next month.
    But it fails for 2 instances in a year.
    From May to June and From October to November.
    This i think is happenning because of the Daylight saving times in the May and October.
    I try to go from May to June but it never does on it's own !! Do i have to explicitly check that for those 2 months or there is any other method ?
    How can i get over it ??
    Please help me with this.
    Shailendra

    Hi
    There may be some other reason for it, coz Day light savings starts in last week of March, not in May.
    And day light savings ends in Last week of October
    Suresh

  • BSP Exception: Missing reference when converting data object ZZxx

    Hi there,
    I have created these new Z fields and tried to include them in a field group. These fields did appear, but they are highlighted with a red box, with the above text in the tool tip.
    Does anyone know what it means??
    Thanks

    I believe they were generated by EEWB - or could've been added manually to the CRMD_CUSTOMER_H. This error only occurs on the Currency fields...something to do with reference field but I just can't find what is wrong with this. I searched up SAP notes and found the following the closest match: -
    <b>Symptom</b>
    when trying to scroll down in the result list in the F4 for the Ibase the error error "BSP exception : Missing reference when converting data object amount.  Correct the entry" occurs.
    <b>Other terms</b>
    CRMT_BSP_IBASE_TREE_NF, data object amount
    <b>Reason and Prerequisites</b>
    This happens due to inconsistancy in structure
    <b>Solution</b>
    Please follow the below steps manually.
    1. Go to tx:SE11
    2. Select data type "CRMT_BSP_IBASE_TREE_NF" in change mode
    3. Select component AMOUNT in 'Components' tab
    4. Go to "Currency/quantity fields" tab
    5. Replace 'Reference table' entry from 'CRMT_BSP_IBASE_DETAIL'
       to 'CRMT_BSP_IBASE_TREE_NF'
    6. Save and activate

  • Converting Date Object

    plz help me,
    I want Date in simple format as dd/mm/yyyy.
    I am retrieving date from database (oracle) and now i want to convert that date to simple "dd/mm/yyyy"
    e.g : date_from_oracle=Wed Feb 01 09:10:59 GMT+05:30 1950
    converted_date=1/2/1950 (and this should be date object and not String)
    System.out.println("converted date:" + converted_date);
    above line should print : converted date:1/2/1950
    if u r clear with my question then plz help me
    Thanks

    No my problem is that i am developping J2EE
    application where i am getting date values in EJB
    that i want to display on JSP page.
    For this i am using struts and passing collection of
    data values to it.That shouldn't make the solution any different.
    My oracle date format is 01-Jan-2005 (dd/mmm/yyyy).
    In my ejb there is one attribute named "date_display"
    of type Date. In Struts Action i retrieved collection
    of all dates from database that i want to display on
    JSP page as it is without any parsing. Then you should not bother about the format.
    If i iterate above collection in JSP page it displays
    date along with GMT and Time format. I dont want
    this. I want to set "date_display" in such a way that
    it should contain date values but in simple format as
    "1-Jan-2005 OR 1/1/2005". Important thing is that the
    Setter Method for date_display accepts parameter of
    Date type. So even SimpleDateFormat also not useful.If it is not useful, write your own method. <_<
    please help me out as i am stuck there.
    System.out.println(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));

  • Converting String to Calendar Object

    Hi,
    I nedd to Change the below String to Calendar Object.i want to show the records which are older than half an hour.any other idea which will solve my problems?
    Fri Aug 17 01:56:40 GMT+05:30 1906
    Thanks in advance.
    Regards:
    Akash.

    Look at
    java.text.SimpleDataFormat

  • Calendar object issues ... recompute remaining fields after change?

    Hello all. I'm doing date manipulation and arithmetic, but I'm running into a problem.
    I'm taking a date provided by a user and comparing it the current date. However, it's the month-end that I'm interested in.
    I'm already creating GregorianCalendar objects from each one, and doing the set on the DAY_OF_MONTH field to the value from getActualMaximum(DAY_OF_MONTH).
    The problem I'm having is that when dealing two dates from the same month, the two Calendar objects are >NOT< returning as EQUAL. After converting each object to a Date and running compareTo() (Side Bar: Why isn't compareTo() available in the Calendar class?) I'm not getting zero.
    I tried a toString() on the two objects, and I can see that some of the fields are not exact ... the time field is "?", WEEK_OF_YEAR, WEEK_OF_MONTH are different, etc. I can see the protected method complete() in the API, but attempts to execute them (gcCurrDate.complete()) yield compile errors stating the method is not visible.
    So how does one ask the system to fill in the remaining fields?
    Thanks!
    Steve

    According to the API docs for Calendar:
    "set(f, value) changes field f to value. In addition, it sets an internal member variable to indicate that field f has been changed. Although field f is changed immediately, the calendar's milliseconds is not recomputed until the next call to get(), getTime(), or getTimeInMillis() is made."

  • Calendar object without time

    Hi,
    I need to get a calendar object without displaying the time (hh:mm) field. Can smone help me with this??
    Thanks in advance

    Thanks for the replies..but my requirement is a
    calendar object which i need to set in one of the
    existing bean class set methods which takes in only a
    calendar object (I cant modify the method signature).
    I am pasting my code below..
    The situation is : I get data from database as a
    string read from a file which is then converted into
    a format yyyy-MM-dd using a simple date format. This
    returns a date object which i need to convert to
    calendar without showing the time fields. The prb is
    it is showing the GMT diff as default.
    public static Calendar dateString2Calendar(String s)
    throws ParseException {
    static SimpleDateFormat df = new
    SimpleDateFormat("dd-MMM-yy");
    static SimpleDateFormat df1 = new
    SimpleDateFormat("yyyy-MM-dd");
    Calendar cal = Calendar.getInstance();          
    1 = null;
         Date d2 = null;
         String S1 = null;
         d1 = df.parse(s);
         S1 = df1.format(d1);
         d2 = df1.parse(S1);     
         cal.setTime(d2);     
         return cal;          
    Req output : 2004-09-07
    Current output : 2004-09-07+05:30
    00:00 also not allowed in the output :(The Calendar object represents a particular moment in time - it does not have a format and it always has a time portion. Do not use the toString() method to display it - if you use the System.out.println() method to display it, the toString() method is being still being called. Format the display using SimpleDateFormat as suggested.

  • How convert Date to Calendar

    i nedd convert a type Date to Calendar or how can increment a Date value in relation with the int value?
    Help me please

    Calendar has a setTime(Date) method, I think. You could look it up, I'm just going from memory. So create a new Calendar object and call setTime on it.

  • Using expression to compare Calendar object

    Hi,
    I wonder if anyone has experience to use expression to compare Calendar object. Here is my case:
    Application {
    Calendar applicationDate;
    What I want is something like:
    expression.get("applicationDate").between(startDate, endDate);
    But it is seems not working this way.
    Any clue?
    Thanks
    Hao

    What error are you getting, in general this should work, however the Calendar will be printed/bound as a java.sql.Timestamp.
    If you require to use java.sql.Date if you just want the date portion of the Calendar.
    If your mapping for applicationDate sets the fieldClassification (i.e. is a TypeConversionMapping), then TopLink will automatically convert the Calendar value in the expression to the correct date type.

  • Is there a way to add event details using a calendar object vs. those dumb field entry boxes?

    I have switched from PC to Mac over a year and a half ago, and have been plagued with the "dumb" date entry boxes in iCal and now Reminders on the mac. For one, they don't show you the DAY OF WEEK for an event, it assumes you are parked on that day, but of course reality sets in and causes constant date changes for events. Picking a date in the future would be much more helpful if Apple followed some usability norms in iCal. For instance, if you are booking a flight online, those helpful little calendar objects pop up, and further, they are smart about "end dates and times" for events, knowing it can't be earlier than the start date. Apple iCal unfortunately always thinks you are creating an ALL DAY event, and when you change the start time, it creates the end time for the next day. Not very smart. Or is it me that is not very smart for constantly hawking every little data entry field for correctness. Why, oh why dear lord has Apple not given some usability attention to iCal on the mac??? At least match the interface of the iPhone with a nice little slot machine rolling control.
    Is there an add in?
    Is there hope that Apple will ever fix its lagging Mail and iCal apps on the Mac?
    Please advise. Or just offer a kind word of consolation if there is no hope for a better interface.

    In the future, Swing related questions should be posted in the Swing forum.
    The code you posted is of little use since it uses custom classes so we can't see the behaviour of your code.
    In general if you add a component to a Container at run time then you just use
    container.revalidate()
    This will invoke the LayoutManager and repaint the components in the container based on the new layout.

  • Urgent. Need help in the Calendar Object.

    Hello developers, best regards!
    Well my problem is that i'm facing a fact that i need a calendar object just like that one when u click the time down there in the taskbar, i need to embedd it in my java windows application.
    To be more clear, if u're familiar with the Visual Basic.NET environment, just the kind of calendars that i need is found there, in which it displays a small box which i can select the months, and accordingly i can select the specific date i need.
    Please i need your help so much.
    Thank you in advance.

    [url http://www.google.co.uk/search?hl=en&q=jcalendar&meta=]click

  • Failed to create deployable object 'local/Calendar' since it not a WD objec

    Hi
    I created a calendar application in Web dynpro,There iam getting this error .will any one please help me how to avoid this.
    com.sap.tc.webdynpro.services.sal.core.DispatcherException: The requested deployable object 'local/Calendar' and application 'CalendarApp' are not deployed on the server. Please check the used URL for typos.
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.getApplicationDeployableObjectPart(RequestManager.java:383)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.initTask(RequestManager.java:317)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:143)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Failed to create deployable object 'local/Calendar' since it is not a Web Dynpro object.
         at com.sap.tc.webdynpro.serverimpl.core.deployment.AbstractDeployableObject.<init>(AbstractDeployableObject.java:106)
         at com.sap.tc.webdynpro.serverimpl.wdc.deployment.DeployableObject.<init>(DeployableObject.java:56)
         at com.sap.tc.webdynpro.serverimpl.wdc.deployment.DeployableObjectFactory.getDeployableObject(DeployableObjectFactory.java:95)
         at com.sap.tc.webdynpro.services.sal.deployment.core.DeployableObjectInternal.getDeployableObjectInternal(DeployableObjectInternal.java:34)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.getApplicationDeployableObjectPart(RequestManager.java:380)
         ... 20 more

    Hi Sushma,
                     lot of new features have been added in CE EHP1 version .for more information refer this [link|http://help.sap.com/saphelp_nwce711/helpdata/en/26/b7fa511a964597a5d8c1b778508936/content.htm] and search in SDN for new features in EHP1 version.
    in CE EHP1, local web dynpro projects cannot be used as it is deprecated in this version.
    i believe this calendar is a local standalone project created in CE 7.1 version and conert this local project to development component.
    right click on ur local project --> Development component -->Convert Project to Development Component.
    After this, go ur NWDI --> select ur component --> right click --> Create project (& Sync ysed Dcs) ..
    finally deploy and run ur component .
    Hope this helps.
    Thanks and Regards

Maybe you are looking for

  • My podcast doesn't open on Safari, but does on Firefox...

    Hi. Sorry if this is explained somewhere else, but I couldn't find it. I'm building a personal website hosted on .Mac, in which i've include a podcast. The podcast was made on Garage Band, and exported to iWeb. I then upload the files to .Mac. Until

  • Submit to Sap button in PDF form

    Hi. I am create two views 1. start view       2. Result View i am enetering data in the Start view and navigation to Result View. in the result view i am displaying all values of start view in the PDF Format. i want to navigate from PDF form to Start

  • POWER Button NOT working... HELP

    My power button just stopped working. Yesterday, the button stopped clicking instantly. As if the button is just stuck in the "down" position. In order for me to turn on the phone now, i have to slide it open. Is this an issue that palm covers under

  • How to use expression in over partition function

    sum(a) over(partition by b order by c range between interval '1' day following and '7' day following) the above query works fine but i want to use like this sum(a) over(partition by b order by c range between interval Trunc(Trunc(sysdate,'MONTH')+1,'

  • How can I sort a string

    Hi, I want to sort a string (daycode), I use the daycode to sort my data. Now i want to sort the daycodes, but i do not know how. Example: the daycode is a10r, so a is the first shift in week (b the second and so on), 10 is the week in year, r is the