Convert RichInputDate to Date object

Hi,
I'm using af:inputDate in my form.
in my backing bean i'm trying to get the value as Date object.
public RichInputDate getFromDate() {
return fromDate;
public void convert(){
Date fromDt = (Date)this.getFromDate().getValue();
but I get this error:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
any idea?
is there a simple way to get the value as Date object.
Thanks!

Converting RichInputDate to specific format
https://kr.forums.oracle.com/forums/thread.jspa?threadID=2242338

Similar Messages

  • Issue with converting string to date object

    Hi all,
    I have a problem with sorting a list of dates in a table column. My dates are in the format 'yyyy-Mmm-dd'(Eg: 2009-Dec-23). Can someone help me how to sort the dates in this format. here is the code which i tried.
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-Mmm-dd");
              Date d1= new Date();
              Date d2= new Date();
              try {
                   d1 = dateFormat.parse("2006-Jun-09");
                 d2 = dateFormat.parse("2006-Apr-10");
              } catch (ParseException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              System.out.println("converted date 1"+ d1);
             System.out.println("converted date 1"+ d2);
    Exception : Unparseable date: "2006-Jun-09"
         }Please someone help me how to pass this date in the right format.

    I believe twisai may have lost the documentation so he/she can figure this out rather than guess that "Mmm" means 3-letter month, first letter capitalized. Let me remind him of the link:
    [http://java.sun.com/javase/6/docs/api/index.html]

  • How to convert a string to date object?

    I have a string user input for date.
    I want to convert it to Date object to insert it in database.
    How to do it?

    Check the java.text.SimpleDateFormat class. You can use it for parsing dates. API contains good description how to build the format pattern.
    HTH
    Mike

  • Adding days to a date object

    I am retreiving a date field from the database.
    i am retrieving that with getDate() method on the result set object.
    that is am retrieving as java.sql.Date object.
    on that date object i have to add 30 days and store it back in the
    database as a date field in database.
    How should i go about handling this problem.
    suppose
    java.sql.Date newDate=rs.getDate(1);
    on this newDate how can i add 30 days and store it back to the database.
    Plz help me out guyz.
    Thanks.

    wud the setting to a particuale date means setting to
    the date i retrieved from the database.
    How to set for a particular date.We have setTime()
    method in Calendar.
    but that takes util.Date object.Then do i have to
    convert the sql.Date object into a util.Date object.A java.sql.Date IS-A java.util.Date.
    (There's no such thing as a sql.Date or a util.Date unless you have a different API than the rest of us.)

  • How to Convert Calender to Date

    Hi.
    I have Calender object (MM dd,yyyy), I wanted to convert this into Date object in the format of "yyyy-mm-dd". Can any one please give me code to do this ?
    Thanks
    Sarav.

    Use Calendar.getTime() to get a Date object corresponding to the point in time that the Calendar represents.
    But note that Dates don't have formats. If you want the time formatted in a particular way, use a java.text.SimpleDateFormat.

  • Date objects and prepared statements

    Hi, I am trying to parse a String into a Date object with format "dd/MM/yyyy hh/mm/ss". Anyway, i have a method in a separate class which reads in a String and converts it to a formatted Date object.
    static public Date convertToDate(String t) throws ParseException {
    Date dd = new Date();
    ParsePosition p = new ParsePosition(0);
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    //y, M, etc are retrieved as substrings of String t. I know these methods are deprecated as well
    dd.setYear(y);
    dd.setMonth(M);
    dd.setDate(d);
    dd.setHours(h);
    dd.setMinutes(m);
    dd.setSeconds(s);
    String formattedDate = formatter.format(dd);
    Date theDate = formatter.parse(formattedDate);
    return theDate;
    Anyway, I am trying to use this in an SQL statement because I am using an Access DB which has a field of Date/Time value. Is this correct to use a Date object then? I have a prepared statement -
    PreparedStatement query = connection.prepareStatement(
    "SELECT FText FROM wnioutput WHERE Id = ? AND Section = ? AND Start = " +
    "? AND Field = ?");
    //start is the Date object returned from the previous method in a separate class
    query.setInt(1, id);
    query.setInt(2, section);
    query.setDate(3, formattedStart); - with this part, i get a setDate method not found, or something
    query.setString(4, ch);
    Can anybody tell me what the problem is? I know there are Date objects of java.util and java.sql. Should i be using an sql Date object? And if so, how, and where do I do this? Thank you!

    ok, i just tried
    query.setTimestamp(3, new java.sql.Timestamp(formattedStart.getTime()));
    where formattedStart is a java.util.Date object
    and I get the following error message -
    Error occured in getting endDateAndTime: java.sql.SQLException: Exception in databaseDisplay: the error message is:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    java.lang.NullPointerException
    where endDateAndTime is
    // takes in the startDateAndTime as a formatted String (before it is converted into a Date object)
    public String getEndTime(int s, int ID, String stDateAndTime) {
    String end = null;
    gui g = new gui();
    try {
    String sql = "SELECT End FROM wnioutput WHERE Id = " + ID +
    " AND Section = " + s +
    " AND Start = '" + stDateAndTime + "' AND Field = 'Wind50m'";
    ResultSet result = g.queryDatabase(sql);
    if (result.next())
    end = result.getString("End");
    } catch (SQLException sqlex) {
    System.out.println("Error occured in getting endDateAndTime: " + sqlex.toString());
    return end;
    Although this method worked fine before. So the error is in setting the date object in the prepared statement. Anymore suggestions??

  • Date object to RichInputDate

    Hello,
    How can i convert Date object to RichInputDate
    Vice versa was possible bt i want it other way round

    Converting RichInputDate to specific format
    https://kr.forums.oracle.com/forums/thread.jspa?threadID=2242338

  • Converting Date.toString() back to a Date object for compare

    I know this is beating a dead horse to death but I have wasted a whole day trying to get this to work. Here is the problem.
    I need to convert a Date().toString (format returned: Dec 19, 2006 3:39:58 PM EST) back to a Date object. What I am doing is writting this string a text file and then revisiting it to compare later to a current Date object to find the difference in the two stamps in milliseconds.
    J2SE 1.4.2 being used
    Date date = new Date();
    String newDateStr = log[1].trim(); // entry from log file
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date logDate = dateFormat.parse(newDateStr);
    // get difference between the two
    long timeSpan = date.getTime() - logDate.getTime();
    if(timeSpan > 60000){
        // TO DO
    }So should I look at a different approach at either:
    A) Storing the date/time stamp in the text file
    B) The conversion back to Date object is wrong
    Really appreciate any insight on this.
    Thanks
    JLW
    Message was edited by:
    jlwestsr

    Then my friend you are in the same status as Tim.:o)
    I don't know as much as him and I don't care to write
    an elaborate reply most of the time. :D
    Merry ChristmasSame to you.I don't pretend to know that much, but When I see something I do know, I tend to give examples.
    Most probably that is because at the present time I am in a situation where most of my time is spent waiting for a call from the customer, and the app I am supporting works so well that those calls are few and far between. Lucky for me, they pay me for sitting around and answering questions on a forum.
    At least it is a java forum, where I can justly claim that I am improving my knowledge of java.
    ~Tim

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

  • How to convert date object format to new?

    Hi,
    I have data object and I want to convert it to this format.
    DD MMM YYYY
    eg: 23 MAR 2003
    I am looking for exact line of code please.
    Thanks,
    Kavans.

    You should check out the Javadoc for java.text.DateFormat and java.text.SimpleDateFormat.
    As for the exact line of code then this would be close:
    Date date = ...; // wherever your date comes from
    DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
    String dateAsString = dateFormat.format(date);Remember to check out those Javadocs, though, 'cos they'll tell you the various formatting options available.
    Hope this helps.

  • How to convert server specific date string into client specific date object

    Hi developers,
    I have a very complex issue to convert the server date string format "EEE MMM dd HH:mm:ss z yyyy" into java.util.Date object and find the difference of the client machine date to represent the elapsed time
    The problem is the server time zone and client time zone are not unique and when I try to covert the server date which is in string format to date format using SimpleDateFormat class , I got the server time as 3:30 hours appended to it. The server time zone is in IST and Client time zone format is GMT+5:30 , the appended time of 3:30 hours created the confusion in calculating the elapsed time between the server started time and client requested time
    I went through all the sites but none of them were useful
    If any help to solve the above issue is appriciated
    please send the response with the same subject line
    Advance Thanks

    Why don't you just subtract from the server time the 3:30 hours (consult api of java.util.date) before comparing with the client date? Hard to see where's the problem...

  • 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

  • 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()));

  • Data objects in Unicode cannot be converted dump

    Hi experts,
    I am using a Custom business object which if run independently throws no error. We are upgrading 4.6 to ECC 6.0.It is unicode active.
    The Business object contains methods for displaying a scanned document from IXOS server.
    On executing work item (for decision step), there is a scanned document which shows up in a window. On closing the window,
    there is a short dump with text 'Data objects in Unicode cannot be converted dump'.
    There are both Before Work item execution method and an After Work item execution method attached in the Methods tab of the task.
    In the After Work item method there is ARCHIVWINDOW_CLOSE function module used. Could there be a problem with this?
    Please help.
    Regards,
    Garima.

    Actually, there is no problem in Workflow.It is because we are upgrading from 4.6 to ECC 6.0.
    I have used CREATE OBJECT ole class and FREE OBJECT statements.
    There is a dump ' Data objects in Unicode cannot be converted dump ' from function AC_FLUSH_CALL_INTERNAL
    occuring when FREE OBJECT statement is executed.
    Please suggest a solution to this.
    Regards,
    Garima.

Maybe you are looking for

  • Snow Leopard install doesn't recognize system disk

    I'm trying to upgrade a MacPro1,1 running Leopard 10.5.8 to Snow Leopard. The system has 3 hard drives, two striped RAID sets, each made with two physical drives and an external hard drive enclosure used for Time Machine. When I run the SL installer,

  • Issue with Mail Adapter ?

    Hi, I am Navneeth, working on Sender mail adapter. We are working on PI 7.1.1 version. We are unable to see the following parameters in the sender Mail adapter:- (1) Default Interface Namespace (2) Default Interface Name. Is it mandatory to maintain

  • Mail crashes when I type certain characters in the "to" or "cc" field

    MacBook Pro Retina 13" 2.6 GHz Intel Core i5 Mavericks 10.9.4 Mail Version 7.3 (1878.6) Not using iCloud. When I type certain characters, mail crashes. It happens with d, D, s, S, (no other single characters) and the sequence "rain", where I can type

  • Component to Composite Video for Ipod touch

    I have a 8gb ipod touch and i have the composite cables for my old ipod so i can watch videos on my tv. I've read that the touch needs the new composite cables and i don't have a hdtv to support that. Is there any converter i can buy to make this wor

  • Files transfer slows down drastically after 362 MB

    i tried restore and update itunes and approximately after 365 mb been transfered it freezes.