DateFormat

I have a string in the format "07/02/2002". I want to convert it into a date. Here's my code
String myDate = "07/02/2002";
Date date = DateFormat.getDateInstance().parse(myDate);
But I got the below exception
java.text.ParseException: Unparseable date: "07/02/2002"
     at java.text.DateFormat.parse(DateFormat.java:312)
Do you have any ideas?

The easiest way to do this is to use java.text.SimpleDateFormat
import java.text.SimpleDateFormat;
import java.util.Date;
// set up the format
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
// parse
Date datToday = sdf.parse("07/02/2002");Hope this helps.

Similar Messages

  • How to convert DateFormat mm/dd/yy to mmm dd yyyy

    Hello, I want to convert from DateFormat mm/dd/yy to a new Date Format that looks like the same date except for the month showing in numbers.
    That is, 09/14/07 would change to Sep 14 2007.
    I've tried to use SimpleDateFormat, where I've specified my DateFormat to MM dd yyyy, but that hasn't helped. Your help will be very much appreciated.

    You want this:
    package cruft;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    * DateFormatDemo
    * User: Michael
    * Date: Sep 14, 2007
    * Time: 7:21:05 PM
    public class DateFormatDemo
       public static void main(String[] args)
          DateFormat inDateFormat = new SimpleDateFormat("MM/dd/yy");
          inDateFormat.setLenient(false);
          DateFormat outDateFormat = new SimpleDateFormat("MMM-dd-yyyy");
          outDateFormat.setLenient(false);
          for (int i = 0; i < args.length; ++i)
             try
                Date date = inDateFormat.parse(args);
    System.out.println("in : " + inDateFormat.format(date));
    System.out.println("out: " + outDateFormat.format(date));
    catch (ParseException e)
    e.printStackTrace();

  • DateFormat parse method usage

    Hi all,
    I am using the following code to parse the date String object to Date Object -
    ======================================================================
    if(dateString == null || dateString.trim().equals(""))
    return null;
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT,
    Locale.getDefault());
    Date d = null;
    try
    dateFormatter.setLenient(false);
    d = dateFormatter.parse(dateString);
    catch(ParseException pe)
    e.printStackTrace();
    =================================================================
    This code works perfectly for all formats of String objects I give except for the format - "12/12/12/1" in which case it converts to following date object -
    "Wed Dec 12 00:00:00 IST 2012" although its an invalid date String.
    Please let me know how I could have correct validation done in such cases or if this is the right behavior for DateFormat class.
    Thanks in advance!!

    I'm not going to comment on how exactly the parse method does its business, but I can suggest you use a regex pattern to validate the input you will send the parse method.
    Here is some info from the CodeProject website on date validation(Note that this is aimed at .NET - but regex works the same in Java as it does in .NET [i think]):
    Dates: As with numbers, we need two validators: a key-press validator, and a completion validator. The key-press validator can be pretty simple, if we limit how our user enters the date. Let’s say that we want to validate for the U.S. date format mm/dd/yyyy. Here is a validator that will do that:
    ^([0-9]|/)*$
    The regex reads: “Match any string that contains a sequence of zero or more characters, where each character is either a digit or a slash.” This validator will give the user immediate feedback if they enter an invalid character, such as an ‘a’.
    Copy that regex to Regex Tester and give it a try. Note that the validation fails if the user enters dashes, instead of slashes, between the parts of the date. How could we increase the flexibility of our regex to accommodate dashes? Think about the question for a minute before moving on.
    All we need to do is add a dash to the alternates group:
    ^([0-9]|/|-)*$
    We could add other alternates to make the regex as flexible as it needs to be.
    The completion validator does a final check to determine whether the input matches a complete date pattern:
    ^[0-2]?[1-9](/|-)[0-3]?[0-9](/|-)[1-2][0-9][0-9][0-9]$
    The regex reads as follows: "Match any string that conforms to this pattern: The first character can be a 0, 1, or 2, and it may be omitted. The second character can be any number and is required. The next character can be a slash or a dash, and is required…” And so on. This regex differs from the ones we used before in that it specifies each character of the pattern—the pattern is more of a template than a formula.
    Note the first character of the regex: ‘[0-2]’. This character points out that we can limit allowable digits to less than the full set. We can also expand them; for example, ‘[0-9A-F]’ would allow any hexadecimal digit. In fact, we can use this structure, known as a character class, to specify any set of characters we want. For example, the character class ‘[A-Z]’ allows capital letters, and ‘[A-Za-z]’ allows upper or lower-case letters.
    Our date regex also points out some of the limitations of regex validation. Paste the date regex shown into Regex Tester and try out some dates. The regex does a pretty good job with run-of-the-mill dates, but it allows some patently invalid ones, such as ‘29/29/2006’, or ‘12/39/2006'. The regex is clearly not ‘bulletproof’.
    We could beef up the regular expression with additional features to catch these invalid dates, but it may be simpler to simply use a bit of .NET in the completion validator:
    bool isValid = DateTime.TryParse(dateString, out dummy);
    We gain the additional benefit that .NET will check the date for leap year validity, and so on. As always, the choice comes down to: What is simpler? What is faster? What is more easily understood? In my shop, we use a regex for the key-press validator, and DateTime.TryParse() for the completion validator.
    Oh - and there is another regex validator:
    ^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$
    which matches the yyyy-mm-dd date format and also validates month and number of days in a month. Could be improved as currently all leap year dates (yyyy-02-29) will validate.
    Sorry if I couldn't be of more help...
    Edited by: JoKiLlSyA on Oct 9, 2008 11:22 PM

  • Problem in parsing date having Chinese character when dateformat is 'MMM'

    I m calling jsp page using following code:
    var ratewin = window.showModalDialog("Details.jsp?startDate="+startDate,window, dlgSettings );
    In my javascript when checked by adding alerts I m getting correct values before passing to jsp,
    alert("startDate:"+startDate);
    In jsp page my code is like below:
    String startDate = request.getParameter("startDate");     
    but here I m getting garbage values in month when the dateformat is 'MMM', because of which date parsing is failing.
    This happens only Chinese character.
    following 2 encoding are already in my jsp page,can anyone help to find solution?
         <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
         <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"/>
    I have even tried to read it as UTF-8 but still that's failing.

    This is my actual code
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    public class TestingDate {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              String dateFormat="EEEE, MMM d h:mm a";
              Date test=new Date(2007,0,19, 19, 31);
              System.out.println(" original date is "+test);
              String stringResult=DateToString(test,dateFormat);
              System.out.println("Date to string is "+stringResult);
              Date dateResult=stringToDate(stringResult,dateFormat);
              System.out.println(" String to date is "+dateResult);
              String stringResult2=DateToString(dateResult,dateFormat);
              System.out.println(" Date to string  is "+stringResult2);
    public static String DateToString(Date test, String dateFormat) {
             String result = null;
             try {
                  DateFormat myDateFormat = new SimpleDateFormat(dateFormat);
                     result = myDateFormat.format(test);
                     //System.out.println(" reslut date is "+result);
              } catch (Exception e) {
                   System.out.println(" Exception is "+e);
              return result;
    public static Date stringToDate(String strDate,String dateFormat1){
         Date result1=null;
         try {
              DateFormat myDateFormat = new SimpleDateFormat(dateFormat1);
              result1=myDateFormat.parse(strDate);
         catch(Exception e){
              System.out.println(" exception is "+e);
         return result1;
    }I am facing problem in getting the actual date. Please suggest the solution.

  • How can we handle dateformat from diff countries into india in bdc with out

    hi
    experts can u help me pz
    how can we handle dateformat from diff countries into india in bdc with out chnaging system parameters while uploading.
    i.e flatfile date is germanformat
         target date is indianformat.
    thanks and regords.

    use WRITE statement to format date.. along with extension ...
    DD/MM/YY
    or
    DD/MM/YYYY

  • Why dateformat matters?

    I am running into a problem with casting on Date, it firstly seems a bug in Oracle DB, but I tried both 9i and 10g and got the same result. Could someone please explain why dateformat matters in this case?
    Thanks in avdance.
    1.
    select BirthDate,
    cast(cast(BirthDate as CHARACTER (60)) as DATE)
    from Employees
    1937/09/19 00:00:00 2037/09/19 00:00:00 <----- ???
    1948/12/08 00:00:00 2048/12/08 00:00:00 <----- ???
    1952/02/19 00:00:00 1952/02/19 00:00:00
    1955/03/04 00:00:00 1955/03/04 00:00:00
    2. use default dateformat
    select BirthDate, to_date(to_char(BirthDate))from Employees
    1937/09/19 00:00:00 2037/09/19 00:00:00 <----- ???
    1948/12/08 00:00:00 2048/12/08 00:00:00 <----- ???
    1952/02/19 00:00:00 1952/02/19 00:00:00
    1955/03/04 00:00:00 1955/03/04 00:00:00
    3. Specify dateformat
    select BirthDate,
    to_date(to_char(BirthDate, 'YYYY-MM-DD' ), 'YYYY-MM-DD')
    from Employees
    1937/09/19 00:00:00 1937/09/19 00:00:00
    1948/12/08 00:00:00 1948/12/08 00:00:00
    1952/02/19 00:00:00 1952/02/19 00:00:00
    1955/03/04 00:00:00 1955/03/04 00:00:00

    The RR format mask exists to help people who still have two digit years. It defines a window for when Oracle assumes a 19xx year and a window for when Oracle assumes a 20xx year. If you are told that something happened in "78", Oracle assumes that you mean 1978 when you use the RR format mask. If you are told that something happend in "04", Oracle assumes that you mean 2004.
    Just to clarify what is happening here, Oracle is evaluating things as follows
    CAST( BirthDate AS CHARACTER(60) )uses the session's NLS_DATE_FORMAT to create a string, i.e.
    "19-Sep-37"Now, it evaluates
    CAST( "19-Sep-37" AS DATE )again using the default NLS_DATE_FORMAT. However, "RR" is not completely reversable, and assumes that "37" here refers to a date in the future, 2047.
    You can modify your NLS_DATE_FORMAT at a session level. Doing so would change the behavior of your CAST statements, which may be desirable if you have existing code that you need to hack to work. Obviously, though, since this is a session-level setting, it can cause maintenance nightmares if different sessions have different settings
    SCOTT @ HP92 Local> create table t1( col1 DATE );
    Table created.
    SCOTT @ HP92 Local> insert into t1 values( to_date('09/19/1937', 'MM/DD/YYYY' ) );
    1 row created.
    SCOTT @ HP92 Local> ed
    Wrote file afiedt.buf
      1* insert into t1 values( to_date('09/19/2037', 'MM/DD/YYYY' ) )
    SCOTT @ HP92 Local> /
    1 row created.
    SCOTT @ HP92 Local> select cast( cast( col1 AS CHARACTER(60) ) AS DATE ) from t1;
    CAST(CAST
    19-SEP-37
    19-SEP-37
    SCOTT @ HP92 Local> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
    Session altered.
    SCOTT @ HP92 Local> select cast( cast( col1 AS CHARACTER(60) ) AS DATE ) from t1;
    CAST(CAST(COL1ASCHAR
    19-SEP-1937 00:00:00
    19-SEP-2037 00:00:00Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to get dateformat from Control Panel? Please help

    Hi,
    I need to get the date format as per displayed in the Control Panel's Regional Options tab.
    May i know how to achieve this in java?
    Please help.

    Thanks for the feedback, actually my code is like this:
    SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.SHORT);
    System.out.println(sdf.toPattern());
    If i open up my Control Panel and change the "Standards and Formats" to "English(United States), the "Short date" field is now showing "7/9/2010" which is "M/d/yy". This matches the format obtained using (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.SHORT). However, it still returns me the format "M/d/yy" after i made the following changes:
    1. Click on the "Customize" button to open the "Customize Regional Options" dialog window.
    2. Select the "Date" tab, from the "Short Date format" drop-down list, choose "MM/dd/yy"
    How can I get the exact date format displayed at Regional Options now, which is "MM/dd/yy"? Please advice.

  • OLAP Query ouput's Dateformat

    Hi  Folks
    I have a OLAP query which returns two columns of type date. When i run MDX query through mdxtest transaction in sap,
    I get the ouptput of date format MM/DD/YYYY
    And when i run same query  through OLAP Query of MII , i get the output with DD.MM.YYYY format
    Any idea why date format is changing from SAP( MDXTEST) TO MII ( OLAP Query ) ? Is it picking date format from MII user profile ?
    Thanks
    Hari

    Test your OLAP query and select text/xml output.  Then in your column that shows the DD.MM.YYYY string observe the associated SQLDataType attribute.  91, 92, 93 will be recognized as date type fields and the QueryTemplate's DateFormat parameter will be used in the html output (the xml will be in the yyyy-MM-ddTHH:mm:ss format).
    If the SQLDataType is a string then the formatting is being done entirely on the OLAP server side and MII is only getting a string and would therefore not be doing any manipulation.
    Since the DD.MM.YYYY format is not a prototypical format you'll see inside MII, and looks more like a SAP GUI type setting, I am speculating that MII is just showing what comes back from the OLAP request, and perhaps it is a user setting from the associated data server connection that is dictating the date format.

  • DateFormat:how to differentiate between 1905 & 2005

    I am writing an application for a mysql database where in I have to populate some very old data in to the database.For that I need to convert dates from the format "MM/dd/yy" into the format "yyyy-mm-dd"( this format being used in mysql).Although I have written the following code to do the conversion, I still have a problem.how do I a make a date like 03/23/06 (06 meaning 1906) to 1906-03-23.Java converts it to 2006-03-23.
    public class Datedemo extends Object {
    String convertDate(String oldate){
    String strdate=null;
    try{
    SimpleDateFormat sdfOutput = new SimpleDateFormat ( "yyyy-MM-dd" );
    DateFormat df=DateFormat.getDateInstance(DateFormat.SHORT,Locale.US);
    Date myDate =df.parse(oldate);
    strdate=sdfOutput.format(myDate);
    }catch (ParseException ae){}
    return strdate;
    public static void main(String args[])
    String newdate;
    Datedemo datedemo=new Datedemo ();
    newdate=datedemo.convertDate("03/23/06");
    System.out.print (newdate);
    How does java recognize whether a year is in this century or in the last. Although for some dates like 03/23/31 java corectly converts it to 1931-03-23 it doesnt do that for some earlier years.
    How do I get around this?Thanks in advance for any help regarding this.
    RS

    As the API documentation for SimpleDateFormat says:
    "When parsing a date string using the abbreviated year pattern ("y" or "yy"), SimpleDateFormat must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the SimpleDateFormat instance is created. For example, using a pattern of "MM/dd/yy" and a SimpleDateFormat instance created on Jan 1, 1997, the string "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/ 64" would be interpreted as May 4, 1964."
    The simplest way to "get around" this is to spell out your dates with 4-digit years. However for those people who didn't learn anything from the Year 2000 problem, there's always the set2DigitYearStart method to bail you out.

  • MM/dd/yyyy OR dd/MM/yyyy DateFormat ????

    i have a string that will be in either of the above formats - anyone know how i can tell which one its in before parsing it ??
    muchos gracias
    schtevie

    Where are you receiving the data from? If this is coming from a browser you can pick-up the locale from the httpservletrequest headers and if it is coming from an ordinary java client then the jre will have a default locale set. Once you have the locale then you can construct a DateFormat object and call parse(String s) to build a date. This relies on them using the ISO-spec'd formats but then again, why wouldn't they? ;-> If you've just got the data from an unknown source you've no chance of being certain but there are far more locales that use dd/mm than mm/dd, (sorry yanks).

  • Setting DateFormat when we update in SalesForce DB

    Hi,
    I want to set DateFormat before updating the date in
    SalesForce Database. I am able to update the date if i select the
    date/month which is greater than 9. Means If i select the date
    10/10/2007 ([MM/DD/YYYY or DD/MM/YYYY format]) its
    updating/inserting the data in SalesForce DB. if i select date
    9/10/2007 it is not updateing why because In SalesForce DB it will
    accept date/month in two digit format --> 09/10/2007 or
    05/08/2007 but not 9/10/2007 or 5/8/2007. Is there any solutions to
    set the dateformat using ActionScript before updating/Inserting the
    date in SalesForce Database.
    Thanks in advance

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team ():
    Hi,
    I need to know some more details to know exactly why the field is not appearing.
    1. Is this an attribute that was included in your EO when you first created it, or one that you added later?
    ARCHANA : This attribute was not included later. It was there when I first created it because it is the "Code" which is the primary key.
    2. Is this attribute in the View Object your JSP insert page is based on?
    ARCHANA: Yes, It is there in the View Object.
    3. Is the View Object your JSP insert page is based on made up of one EO, or is it based on more than one EO?
    ARCHANA : The View Object is based on one EO only.
    4. In your JSP, you can try adding the following code to see if the attribute field will get displayed:
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <%
    RowEditor.initialize(application, session , request, response, out, "theModule.theView");
    RowEditor.setTargetUrl("theView_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.setDisplayAttributes("Attr1,Attr2...");
    (enter the names of the attributes you want displayed in the setDisplayAttributes method.
    Laura<HR></BLOCKQUOTE>
    Actually my JSP has exactly the same code as u have sent. I have included "Code" in my setDisplayAttributes() method also. The label for this attribute appears but adjacent to it there is no text control to type the data when I insert data.
    Please explain.
    null

  • DateFormat as Cell Renderer

    I am trying to use a DateFormat object as a Rederer for a table column.
    This is the Code I'm using:
    DateFormat df2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); //defines a date format.
    list = new javax.swing.JTable();
    TableColumn col = list.getColumnModel().getColumn(0);
        col.setCellRenderer(new MyTableCellRenderer());
    public class MyTableCellRenderer extends JLabel implements TableCellRenderer {
            // This method is called each time a cell in a column
            // using this renderer needs to be rendered.
            public Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
                // 'value' is value contained in the cell located at
                // (rowIndex, vColIndex)
                if (isSelected) {
                    // cell (and perhaps other cells) are selected
                if (hasFocus) {
                    // this cell is the anchor and the table has the focus
                // Configure the component with the specified value
                setText(df2.format(value));
                // Set tool tip if desired
                //setToolTipText((String)value);
                // Since the renderer is a component, return itself
                return this;
            // The following methods override the defaults for performance reasons
            public void validate() {}
            public void revalidate() {}
            protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
            public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
        }The table holds data that I pulled in from an SQL database query. The Query works fine, I get my row of data, break it up into a Vector, then add it to the table model.
    Code:
                       pst=sqlConnection.prepareStatement("SELECT * FROM taxilogdb ORDER BY id DESC LIMIT 1");
                        rs=pst.executeQuery();
                        while(rs.next()){
                            v.add((Date)rs.getTimestamp("timegiven"));
                            v.add(rs.getString("location"));
                            v.add(rs.getTimestamp("arrival"));
                            v.add(rs.getTimestamp("pickup"));
                            v.add(rs.getString("destination"));
                            v.add(rs.getDouble("fare"));
                            v.add(rs.getDouble("paid"));
                            v.add(rs.getDouble("check1"));
                            v.add(rs.getDouble("charge"));
                            v.add(rs.getTimestamp("clear"));
                            v.add(rs.getBoolean("CMO"));
                            v.add(rs.getBoolean("saferide"));
                            v.add(rs.getBoolean("timecall"));
                            v.add(rs.getBoolean("passed"));
                            v.add(rs.getBoolean("personal"));
                            v.add(rs.getBoolean("roadcrew"));
                            v.add(rs.getBoolean("walkup"));
                            v.add(rs.getString("chargeName"));
                            v.add(rs.getInt("ID"));
                        model.insertRow(0,v);
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }When I run the app, I get an exception:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.sql.Timestamp
    at TaxiLogUI.TaxiLogUI$MyTableCellRenderer.getTableCellRendererComponent(TaxiLogUI.java:3589)
    at javax.swing.JTable.prepareRenderer(JTable.java:3924)
    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2070)
    I'm guessing from the Exception it is a result of trying to format the data as a Date. What I don't understand is that I Cast the SQL Timestamp to a Date, and as far as I can tell, that works fine. I verified that the issue is NOT when I break up the result set from the SQL Query, So I am not 100% sure where it's coming from. Why is it generating this exception? What should I read up on?? I'm stuck . Thanks.

    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained,
    Compilable and Executable, Example Program that demonstrates the
    incorrect behaviour, because I can't guess exactly what you are doing
    based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its
    original formatting.

  • Dateformat in a LOV-Column

    Hi,
    can somebody tell me how I can set a dateformat for a LOV-Column in Forms 9.0.2.12.2.
    I want to have it to look like this: "2.Aug.2005" instead of "02.08.05".
    Thanx and regards
    Helmut

    Write your LOV with an extra column that contains the date formatted how you want it. Don't display your real date, just the formatted one. Your select statement would be something like:
    SELECT TO_CHAR(TO_DATE('02/AUG/2005','DD/MON/YYYY'),'FMDD.Mon.YYYY') displayed_date,
    '02/AUG/2005' the_date
    FROM dual
    Richard

  • DateFormat.parse(String)

    can anybody tell me why I don't get a SHORT format:
    import java.util.*;
    import java.text.*;
    public class MyDate{
       public static void main(String[] args){
          Date date = makeDate("04/22/2003");
          System.out.println(date); // what i get looks more like FULL
        public static Date makeDate(String dateString){
           Date date = null;
           try {
              DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
              date = fmt.parse(dateString);
          catch(ParseException e) {}
          return date;
    }Thank you.

    what I think is tripping you up is that a java.util.Date is not a String. It looks like you're thinking that you can format a java.util.Date object and somehow it is "11/23/2004" (or whatever) - but it's not - it's just a number. So, you have this String that you want to convert to a java.util.Date (which you correctly did with the parse method of the DateFormat class) but then you turn around and want to convert that java.util.Date to a String so you can put it into a List, so why not just put the original String into your List? Is it because you want to change the format? Fair enough, then you can use two DateFormat implementations, one to parse the incoming String to a Date, then the other to format the Date to the format you want. Or is it so you can do the sort chronologically? If that's the case, then you can write up a Comparator to do that, or you can store Dates in your list, sort them, and when it comes time to display this thing (if you ever do that) use a DateFormat implementation to convert those to a formatted String.
    Make sense?

  • DateFormat parse problem

    Hello all,
    I'm trying to parse a simple date, using java version 1.4.12, but for some reason an exception is thrown. Here is the code:
    DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
    Date date = format.parse("Nov 4, 2003 8:14 PM");
    Can anyone help?
    Thanks

    I always use SimpleDateFormat. One thing might be that the parsing pattern returned for your default locale doesn't match your input String.

Maybe you are looking for