Simple date format probem

i wrote a method to convert a String to Calendar, but i have an error.
The calendar object generated always has the month set to january and i don´t know why.
This is my code
     static SimpleDateFormat df=new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
                      public static Calendar dateString2Calendar(String s) throws ParseException {
          Calendar cal=Calendar.getInstance();
          Date d1=df.parse(s);
          cal.setTime(d1);
          return cal;
     }  if the source String is: 2008-09-04 17:54:09 my Calendar gets the value: Fri Jan 04 17:54:09 CET 2008
Where is my mystake?
Regards

upps i am feeling very very stupid....
anyway thanks BigDaddyLoveHandles !!!!!!!

Similar Messages

  • Regarding simple date format

    Hi,
    Can any one please tell what is simple date format for below format.
    2008-11-04T11:49:04.312-04.00

    Basil wrote:
    I think all are getting confused with my question, I dont want to know how to convert date
    to a a particular format, I want to know if there is any format for 2008-11-04T11:49:04.312-04.00
    like yyyy-MM-dd'T'HH:mm:ss.SSS for 2008-11-04T11:49:04.312. My JDK version is 1.4
    Edited by: Basil on Nov 4, 2008 7:43 AM
    Edited by: Basil on Nov 4, 2008 7:43 AMRead the link for SimpleDateFormat and make one. How is that hard to understand? And it is what you have been being told from the beginning, and would have realised had you actually read the API docs pointed to. All the information you need to do so is there.

  • Simple Date Format

    Hi,
    I have an entity object with some attributes, one of them is called "CREATED_ON", which i have specified as a history column (created on).
    I have specified a format type of Simple Date in my Control hint and a format of dd-MM-yyyy. I then created a view based on my entity and dragged the view as an adf creation form. I also dragged a commit button to commit my record.
    However, the date that is stored in my database have a non-zero time component (e.g. 10-JUL-2007 10:46:22). This is a problem becuase in my search form, the search criteria does not work (it requires the exact time also to work). I do not want to use TRUNC in my SQL query.
    Instead i want the date to be stored with the format mask that i have specified.
    Can you please help me?
    Thank you

    Do you really want to lose the time component altogether, or just make the query on date-without-time work?
    There would be no way of recovering the information about when during the day the row was created if you truncate the time information, but it's possible to achieve if that's what you want. Both are possible to achieve.
    To achieve the "losing the current time info forever" approach, add the following overridden method in your entity impl class that slightly changes the way the history attribute value is returned, in my case, for the HIREDATE attribute of an Emp example:
        protected Object getHistoryContextForAttribute(AttributeDefImpl attributeDefImpl) {
            Object ret = super.getHistoryContextForAttribute(attributeDefImpl);
            if (attributeDefImpl.getIndex() == HIREDATE) {
                ret = new Date(new java.sql.Date(((Date)ret).getValue().getTime()));
            return ret;
        }To achieve # 2 instead, just add a SQL-derived attribute to the view object with formula:
    TRUNC(HIREDATE)and then use that sql-derived attribute in the query form instead of the normal HIREDATE attribute.

  • Simple date format update/cleansing not working

    Dear All,
    Some rows are not being updated after update
    create table X(
    Surname varchar2(20),
    dob varchar2(20),
    dobupdate varchar2(20));
    insert into X values('Hookman','22-Apr-78','22-Apr-78');
    insert into X values('Beverly','21/06/1966','21/06/1966');
    insert into X values('Wickham','01/23/1985','01/23/1985');
    insert into X values('Logmann','26/Dec/1972','26/Dec/1972');
    insert into X values('Scooby','30.04.1966','30.04.1966');
    insert into X values('Trumph','15-August-1967','15-August-1967');
    insert into X values('Delaware','Aug-03-1961','Aug-03-1961');
    insert into X values('Wicked','03.Sep.1961','03.Sep.1961');
    insert into X values('Orlando','18.September.1961','18.September.1961');
    SURNAME DOB DOBUPDATE
    Hookman 22-Apr-78 22-Apr-78
    Beverly 21/06/1966 21/06/1966
    Wickham 01/23/1985 01/23/1985
    Logmann 26/Dec/1972 26-DEC-1972
    Scooby 30.04.1966 30-APR-1966
    Trumph 15-August-1967 15-August-1967
    Delaware Aug-03-1961 03-AUG-1961
    Wicked 03.Sep.1961 03-SEP-1961
    Orlando 18.September.1961 18.September.1961
    9 rows selected.
    =====================================
    --Code below is meant to update person Beverly
    Update x set dobupdate = to_char(to_date(dobupdate,'DD/MM/YYYY'),'DD-MON-YYYY')
    where dobupdate like '__/__/____';
    error - not valid month
    =======================================================
    --Code below is meant to update person  Trumph
    Update x set dobupdate = to_char(to_date(dobupdate,'DD-MONTH-YYYY'),'DD-MON-YYYY')
    where dobupdate like '__-_____-____';
    0 row/s updated
    =========================================================
    --Code below is meant to update person Orlando
    Update x set dobupdate = to_char(to_date(dobupdate,'DD.MMMM.YYYY'),'DD-MON-YYYY')
    where dobupdate like '__._____.____';
    0 row/s updated
    Where am I going wrong. I hvae no problems with updating other records in the table except fot just these three patterns.
    Help please.
    Cube60

    Thanks Warren, both suggested codes did not work and I can see why now. Alex has pointed it out.
    Alex brought me to realise Wickham's DOB is in the American format. The update query could not resolve that format and how to update it but at least it could have updated that of Beverly and left that of Wickham.
    After deleting Wickham completely, the update query worked on Beverly.
    Am just doing some data cleansing from a poorly designed Access database now meant for Oracle.
    So nothing can be done to resolve such mixture of date formats, I mean Uk and American.
    But now, Why are the update statement below coming with 0 records updated.
    The dates to be update are written like this 15-August-1967 and 18.September.1961 respectively
    --Code below is meant to update person Trump
    Update x set dobupdate = to_char(to_date(dobupdate,'DD-MM-YYYY'),'DD-MON-YYYY')
    where dobupdate like '__-__-____';
    0 row/s updated
    =========================================================
    --Code below is meant to update person Orlando
    Update x set dobupdate = to_char(to_date(dobupdate,'DD.MMMM.YYYY'),'DD-MON-YYYY')
    where dobupdate like '__._____.____';
    0 row/s updated
    many thanks
    cube60
    Message was edited by:
    cube60

  • Help :  Simple Date Formats Problem in JDev11 [TP4] ?

    Hi ;
    I use ADF/JSF in JDeveloper 11 [TP4].
    in JSF Page
    what can I do to enter Date format mask dd-mm-yyyy hh:mi:ss
    to Return my Date Format mask like
    mi-mm-yyyy meaning minute-month-year
    in another column ?
    and I know The format mask is defined in a File called formatinfo.xml .
    Thanks & Regards
    Forakora

    Hi,
    if it is for display then you don't need to change it in the model but can link the output text component to a managed bean that gets the stored date value to then change it to the format you prefer. This however may not be suitable if the date should be updated from that column

  • Simple date format with 1st 2nd 3rd etc

    hai
    i want to dispaly the date in the format
    25th of December 2004
    i tryed to format in SimpleDateFormat, but there is not special format to display date as 1st 2nd 3rd.
    can anybody help me how to do this
    Archi

    THANKS YOU
    THANKS FOR YOUR VALUABLE RESPONSE
    THAT I KNOW VERY VERY WELL HOW TO DO THAT.
    ITS URGENT I DONT WANT TO WASTE TO "INVENT A NEW STUFF"
    ARCHI.

  • Reading simple date format

    Hi,
    I am attempting to use the simpledateformat in Java. I want it to read the inputted code, and store it, and then print it out again...
    Here is what I have so far:
    import java.util.*;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    public class Date     {
         //For date :
         static DateFormat df = new SimpleDateFormat("dd-mm-yyyy");
         public static void main(String[] args)
              //for date in form (dd-mm-yyyy)
              //reads input fromm keyboard
              Scanner data = new Scanner(System.in);
              //Asks for you to type in date.
              System.out.println("Useby date: (dd-mm-yyyy)");
              //Takes input as string value
              String input = data.next();
              Date useby = null;
              try
                   useby = df.parse(input);
              catch (ParseException e)
                   e.printStackTrace();
              //Prints useby date.
              System.out.println("Useby date: " + df.format(useby));
    The line:
                   useby = df.parse(input);
    States that there is a type mismatch... "cannot convert from Date to Date"??? What does this mean???
    I am unsure as to what all these lines mean as I got them off the net and was unsure about some of them...
    If some1 could help it would be very much appreciated.
    Thanks.

    I think your code is getting confused between java.util.Date and your own class's name, which is Date. Rename your class, and you should be fine.
    By the way, please use code tags when posting code. See CODE button above posting box. That will format your code such that it is much more readable.

  • Does Simple Date Format suppourts This convrsion??

    Hi ,
    I am getting this Date as String
    String str = "Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)";
    How to convert this Date Object into yyyy-mm-dd HH24:Mi:ss Format ??
    I have not seen any example using SimpleDateFormat with this format ??
    Please can anybody please show me how to do this ??

    user10503747 wrote:
    Hi ,
    I am getting this Date as String
    String str = "Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)";
    How to convert this Date Object into yyyy-mm-dd HH24:Mi:ss Format ??
    I have not seen any example using SimpleDateFormat with this format ??
    Please can anybody please show me how to do this ??The following works for me.
    String str = "Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)";
    str = str.replace("GMT ", "GMT +");
    SimpleDateFormat sf = new SimpleDateFormat("EEE MMMMMMMMMMM d yyyy H:m:s 'GMT' Z");Although not relevant to your actual problem the above will not work if '-' is used instead of the '+'. No idea why that is. It parses but seems to ignore the offset in that case.

  • Simple Date Format problem

    I am having trouble with the following code. It works fine on one computer but not on another.
    Calendar cal = Calendar.getInstance(TimeZone.getDefault());
    Date date22 = cal.getTime();
    System.out.println(date22);
    String details = sdf.format(date22);
    System.out.println(details);
    StringTokenizer str = new StringTokenizer(details, "-", false);
    The working ones output is:
    Thu Jul 14 12:06:33 GMT 2005
    14-07-2005-12-06-33
    However on the computer where it doesn't work, I get this:
    Fri Aug 05 13:13:59 BST 2005
    Exception in thread "Thread-0" java.lang.NullPointerException
    Which point to line: String details = sdf.format(date22);
    From what I can see, the only difference is BST instead of GMT, but I can't seem to change this.
    It is running under Windows.
    Any help will be MUCH appreciated, as I am stumped!
    Thanks. :)

    The difference is that in the latter sdf is never assigned a non-null value. Since you didn't post the code that initializes sdf, we've got no way of knowing what went wrong.

  • Regarding java.util.date / simple date format

    Hi Friends,
    I have a weired requirement where I am suppose to get time in millisecond for 3 scenarios.
    1. next 07:00 time
    2. next monday 07:00
    3. on next 1st 07:00
    Swing provides some jar where I can get next day - but not sure if I can play around to get my data.
    need your inputs.
    appreciate your quick reply friends,
    Chintan
    P.S. the reason I have to do so is
    1. I have 3 kind of reports - few reports expire daily - few weekly - few monthly.
    2. I am going to fetch the report from the external system and store (cache) in my db.
    3. Administrator can configure that when exactly the report is going to be updated in external system.
    4. So lets say for daily - every day at 7 it will be updated - so when I read the cached data, I want to compare the stored time stamp with next 7:00 time stamp and if my stored timestamp is less than next 7:00 time stamp - i can use the cached data and similarly for weekly and monthly.
    Please let me know if you have more questions.

    I'll just add an example.
    say I added a report to DB at 1188563489217 and my
    cutoff is weekly that is on next monday at 7:00 in
    the morning - at that time my milliseconds would be
    1188783033888
    now as far as my stored milliseconds are less than
    1188783033888 i can read it from my db and if my
    stored milliseconds are greater than 1188783033888
    then I need to refetch the report.
    Now for this task - every time i make a call to my DB
    - i have to get time in milli seconds for next monday
    7:00.
    Is it possible??
    I am badly struck over here - please guide.
    Chintan
    Appreciate your help buddies.
    ChintanTake the hint if the date string is 35:11:2007 07:00 in dd:MM:yyyy HH:mm format then the parsed date will be 05:12:2007 07:00.
    your problem is actually a piece of cake ;-)

  • Simple Date Formatting

    I am a newbie to Java and was wondering if anyone knew of a easy way to format and date without having to write a whole function to format a date??

    I need more information what you are trying to do?
    Do you want to convert a string to a date are a date in one format to other.
    I suggest you to go through the following class API
    SimpleDateFormat
    Hope this will help you get some info about formatting
    Happy Coding
    Sampath

  • Format date with simple date format

    Hello
    I want to parse String to date. My method is
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Then
    Date date = dateFormat.parse("2007-17-1100 11:11");
    It can be seen that the String "2007-17-1100" is invalid date. However, I donot know why it still can be parsed. Result is "Thu May 05 11:11:00 NZST 2011"
    Could you please explain. I want this one cannot be parsed.
    Many thanks
    shoa

    SimpleDateFormat dateFormat = new
    SimpleDateFormat("yyyy-MM-dd HH:mm");
    Then
    Date date = dateFormat.parse("2007-17-110011:11");
    >
    IIn my knowledge there is only 12 months in a Year.There are. But as long as the parsing is 'lenient' it knows how to handle month numbers greater than 12.
    @OP: Check out the setLenient() method. A setLenient(false) should make it work the way you want.

  • Problem with  date format "dd-MM-yyyy"

    hi all,
    i am using jdev 10.1.3.2
    My application ADF Swing app.
    in my database i have a table employee which contains "birthday".
    my problem is that i must use date format"dd-MM-yyyy".
    i added this format into "formatinfo.xml" file.
    than i choose it in my EO.
    i create a form which contains employees.
    for example i have an employee with a birthday=25-10-1970
    in my text field if user puts "1970-10-25"'which is not the best format) he will have a correct result "25-10-1970"
    but if user puts "25-10-1970" he will have as result "21-02-0031" which is not the real value.
    please help me.
    thanks.
    PS: i did some research before posting but i didn't find yet

    Rouz,
    Did you try what i said before?
    * Open you EntityObject
    * Expand the attribute tree
    * Choose your DOB attribute
    * Choose the Control hints pane on the right
    * Choose Formater: Simple date format
    * Choose Format mask dd-MM-yyyy
    Run your application and try it.
    This is how i change the format and it works perfectly.
    I uses the correct format to show the date and it enables me to edit the date using the format mask dd-MM-yyyy
    Edit: I just tried it myself. I can only reproduce it by removing my mask. Ergo, the application expects the default american format yyyy-MM-dd. By entering a date in the format dd-MM-yyyy the framework will convert it to yyyy-MM-dd and you'll end up with 0031-02-21.
    CONCLUSION follow the steps i discribed above to set your mask and you'll be fine.
    Message was edited by:
    Smolders Johan

  • BC4J Date format mask

    After specifying a date format for an attribute of an entity object using Entity Object Editor - Control hints on the attributes.
    Format type: Simple Date
    Format: dd/MM/yyyy
    When inputting the date manually rather than using the date picker, if only 2 digits are supplied for the year i.e 01/01/02 the resulting date is 01/01/0002, is there any way to force this so the user has to input 4 digits for the year?
    Thanks

    In a form you can set the format mask item property
    whatever you want.
    Usually we try to use DD-MON-YYYY without enclosing it single quotes. but you can try
    ' . . ' or simplly . .
    and see what happens.
    Suresh

  • Date formating issue

    Hi All,
    I am receiving the Begin Date and End date from one of the RFCs and then using these dates for the import parameters of another RFC.
    But the second RFC receives the dates either in YYYYMMDD or DD.MM.YYYY format.
    The BeginDate and EndDate of the first RFC are binded to two input fileds so they appear as Date pickers in the runtime.
    As I select the date range , I need to execute the second RFC before submition and so the Import of the Second RFC should receive the date range .
    I have gone through many Forum threads but the way they are suggesting, returns me no right result. If I follow the Simple date Format, I parse the date and have a String output which the second RFC does not accept.
    And if I assign the parsed value to the a Date type then I receive a null value for the same. I need your help , please suggest and guide.
    Regards
    DK

    Hi Mohanthy,
    As you told, BeginDate and EndDate of the first RFC are binded to two input fileds and the values of BeginDate and EndDate has to be sent as input fields to another RFC.
    Just get the values from the node generated by first rfc and set them to the i/p node of second rfc.
    Date Format should not be  a issue in this case and for your information the date which is used by RFC is Java.SQL.DATE Class.
    Regards,
    Kiran Kumar

Maybe you are looking for

  • Setting Vertical alignment

    I know how to set vertical alignment in a Microsoft Word document. I have been unable to find out how to do the same thing in Pages '08. I know it has to be there because if I open a document in Pages that was created with Microsoft Word that has ver

  • Question about action maps

    I have an action that applies to both a jTextField and a jButton     public class ActionOnFormat extends AbstractAction implements FocusListener {         public String[] formatNames = {"fixed","sci","eng","float"};         protected int formatSpec;

  • How to make a jframe or jdialog on top of all other applications

    I just want to know if there a way to make a jframe or jdialog on top of an application like games? Thanks in advance...

  • Windows SharePoint Services Connector for WebDAV is now available

    The Windows SharePoint Services Connector for WebDAV is now available for download as described in my <a href="https://weblogs.sdn.sap.com/pub/wlg/4128">weblog</a>.

  • DB Comparing Tool

    Hello, Can some one tell me a tool which will help to identify the differences between two databases? i.e Table Structures, Changes in data etc., Sorry...I dont think this is a correct forum to ask this question. But I dont know where to ask this. So