Convert a String Mar 7, 2008 to date in yyyy-dd-mm format

Hi,
Please help me to Convert a String Mar 7, 2008 to date in yyyy-dd-mm format..
have to store that Date in SQL Server date field in yyyy-dd-mm.
Regards,

I done this and got the desired result 2008-03-07. Thanks... know checking it with my code :)
String ss = "Mar 7, 2008";
          //System.out.println(ss);
          try{
          SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, yyyy");
          Date date = dateFormat.parse(ss);
          System.out.println(date.toString());
          System.out.println(new java.sql.Date(date.getTime()));
          }catch(Exception ee)
               ee.printStackTrace();
          } //endsEdited by: bunty_india on May 8, 2008 8:09 PM

Similar Messages

  • How to convert JAVA.SQL.DATE date in YYYY/MM/DD format into DD/MM/YYYY

    i am using informix database which accepts date value in the form of DATE format......
    the other part of my application takes date from the field in DD/MM/YYYY format...so i have to convert my java.sql.date in YYYY/MM/DD fromat into DD/MM/YYYY fromat of same type before inserting into db......
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........

    816399 wrote:
    i am using informix database which accepts date value in the form of DATE format......Huh?
    Maybe you mean Informix (fronted by JDBC) expects date values as java.sql.Date objects?
    the other part of my application takes date from the field in DD/MM/YYYY format...
    so i have to convert my java.sql.date in YYYY/MM/DD format into DD/MM/YYYY format of same type before inserting into db......I am not sure why you are talking about formats here.
    There is no formatting inherent in a java.util.Date object
    nor in a java.sql.Date object.
    but using parse method in SimpleDateFormat class can get the result only in java.util.date format...
    and also using format method can result only in string conversion........You can easily create a java.sql.Date object from a java.util.Date object.
    String s = "31/12/2010";
    java.util.Date ud = new java.text.SimpleDateFormat("dd/MM/yyyy").parse(s);
    java.sql.Date sd = new java.sql.Date(ud.getTime());
    ud = sd; // java.sql.Date extends java.util.Date so no conversion is needed

  • Formatting a date in YYYY-MM-DD format in a grid in We dynpro abap

    Hi All,
    I have the requirement to display a date in YYYY-MM-DD format in a salv_wd_table grid .
    when i selecting the date from the calender that attached to a column in the grid will show in DD-MM-YYYY format.
    Please help in this.

    >
    Manoj Kumar wrote:
    > Hi Abhimanyu  ,
    >
    > I don't want like that.
    > Iwant to know is there any other way apart from this or any property to set the format of a column in salv grid.
    ABAP is pretty good about automatically using the user's profile settings for formatting. That enforces consistency across applications.  If you want to override this, you will need to do it at the data level.  Instead of defining this field in the context as a data - define it like a string or char10.  Then when you populate the data within your business logic do a WRITE statement from the data field to the character field.  During the WRITE command you can specify the date formatting option:
    From the online syntax of WRITE:
    Addition 15
    ... DD/MM/YY   | MM/DD/YY
      | DD/MM/YYYY | MM/DD/YYYY
      | DDMMYY     | MMDDYY
      | YYMMDD
    Effect: These additions influence the output of data objects of the data type d. In all other data types, the addition is ignored.
    The content of a data object of type d is interpreted as a valid date in the format YYYYMMDD and is output as follows for the individual additions:
    DD/MM/YY and MM/DD/YY:
    Both additions have the same effect. The date output has a two-digit year value and a separator. The separator and the order are taken from the definition for date output in the user master record.
    DD/MM/YYYY und MM/DD/YYYY:
    Both additions have the same effect. The date output has a four-digit year value and separator. The separator and the order are taken from the definition for date output in the user master record.
    DDMMYY und MMDDYY:
    Both additions have the same effect. The date output has a two-digit year value and no separator. The order is taken from the definition for date output in the user master record.
    YYMMDD:
    This addition provides a date output with a two-digit year value without a separator in the format YYMMDD.
    But even this approach is going to have limited impact. It will only let you chose between the allowed formatting types from the user master.  YYYY-MM-DD is not one of those formats.
    So if you really want a non-SAP formatted date you will have to break it up yourself.  The internal date format is always stored as YYYYMMDD. You can just parse it out:
    data year type char4.
    data month type char2.
    data day type char2.
    year = sy-datum+0(4).
    month = sy-datum+4(2).
    day = sy-datum+6(2).
    data date_string type char10.
    concatenate year `-` month `-` day into date_string.

  • Can we configure Oracle 10g xe so that it accept date in yyyy-mm--dd format

    I am facing problem in inserting and updating data in oracle server through jdbc. its java.sql.Date class sends date in yyyy-mm-dd format while oracle requires date in dd-mmm-yy format. can we configure oracle server in such a way that we may send date in yyyy-mm-dd format to insert and update?

    People should be sure of their information before
    posting, even more so if they have an Oracle Ace
    credential,as they're more likely to be believed. Not sure what you are saying.
    The way I read it, Avi stated that overriding the NLS_DATE_FORMAT as an initialization parameter WILL NOT affect the way XE works, and you still need to set the parameter at the session level.
    This is true.
    As demonstrated here, where I
    - startup my XE (SuSE 10.1 Pro/Linux),
    - show the NLS setting,
    - log on to a regular user, -
    - show the system date,
    - change the NLS_DATE_FORMAT system wide by updating my PFILE,
    - restart the database
    - show the NLS_DATE_FORMAT
    - extract the system date.
    As you see from the console session, the date still comes out in the format defined by the NLS_TERRITORY, in spite of what the global NLS_DATE_FORMAT indicates.
    fcc@fuzzy:~> su - oracle
    Password:
    oracle@fuzzy:~> sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jul 6 08:06:05 2007
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to an idle instance.
    SQL> startup
    ORACLE instance started.
    Total System Global Area  448790528 bytes
    Fixed Size                  1259400 bytes
    Variable Size             134219896 bytes
    Database Buffers          310378496 bytes
    Redo Buffers                2932736 bytes
    Database mounted.
    show parameter nls_date
    Database opened.
    SQL>
    NAME                                 TYPE        VALUE
    nls_date_format                      string
    nls_date_language                    string
    SQL> connect test/test
    Connected.
    SQL> select sysdate from dual;
    SYSDATE
    06-JUL-07
    SQL> alter session set nls_date_format='YYYY Mon DD';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    2007 Jul 06
    SQL> connect / as sysdba
    Connected.
    SQL> select sysdate from dual;
    SYSDATE
    06-JUL-07
    SQL> create pfile='/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/xe.pfile' from spfile;
    File created.
    SQL> !vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/xe.pfile
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup pfile=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/xe.pfile
    ORACLE instance started.
    Total System Global Area  448790528 bytes
    Fixed Size                  1259400 bytes
    Variable Size             134219896 bytes
    Database Buffers          310378496 bytes
    Redo Buffers                2932736 bytes
    Database mounted.
    Database opened.
    SQL> connect test/test
    Connected.
    SQL> connect / as sysdba
    Connected.
    SQL> show parameter nls_date
    NAME                                 TYPE        VALUE
    nls_date_format                      string      YYYY Mon DD
    nls_date_language                    string
    SQL> connect test/test
    Connected.
    SQL> select sysdate from dual;
    SYSDATE
    06-JUL-07
    SQL>                                                            

  • Unable to get date in yyyy.MM.dd format

    Hi All
    I am unable to get date in yyyy.MM.dd format.
    I tried everything said in the previous postiongs.Nothig seem to work.
    I am getting date in yyyy-MM-dd
    This needs to be changed in said format. Also datatype should be date only.
    Regards
    Pratyush

    You can solve the problem in two ways
    First way;
    Format formatter = new SimpleDateFormat("yyyy.MM.dd");
    String s = formatter.format(date);
    OR
    Assuming your context attribute name is Date
    IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("Date");
    attributeInfo.getDataAttribute().getScalarType().format("yyyy.MM.dd");
    Second way;
    By changing the default Language of your browser. You have to check the format of each language and choose the language that gives the date in yyyy.MM.dd format.
    Rgs,
       Dni

  • Want date into  'yyyy/mm/dd' format

    Hi
    all
    Im creating date onject like
    Date d = new Date();
    but date object d is availabe with date and time.
    i want to exctract date into 'yyyy/mm/dd' format.
    can anybody helpe in this case
    Help will be appricated.
    Thanx
    sanjay

    You are hereby served with notice of a hearing to be held in 18th Circuit Court of Seminole County, FL, on 12 April 2005 to answer a suit brought against you for spoon-feeding. You have 15 days upon receipt of this notice to provide written response to the original filing (see Attachment A).
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Want Date in 'yyyy/mm/dd' Format

    Hi
    all
    Im creating date onject like
    Date d = new Date();
    but date object d is availabe with date and time.
    i want to exctract date into 'yyyy/mm/dd' format.
    can anybody helpe in this case
    Help will be appricated.
    Thanx
    sanjay

    Hi
    Try this:
    SimpleDateFormat time = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    time.format(new Date()

  • [Oracle 8i] How to convert a string (time stamp) into a date?

    I'm having difficulty figuring out how to convert a time stamp string into a date (or possibly a number).
    The time stamp is 20 positions, character (NOT NULL, CHAR(20))
    in the format: YYYYMMDDHHMMSSUUUUUU
    where Y = Year, M = Month, D = Day, M = Minutes, S = Seconds, and U = Microseconds
    The reason I want to convert this is so that I can compare one time stamp to another (i.e. I want to be able to find the MIN(timestamp), MAX(timestamp), and do inequality comparisons).
    Is this at all possible?
    Thanks in advance for help on this!

    Hi,
    As Damorgan said, if all you want to do is find which is the earliest or latest, then you can just compare the strings: they happen to be in a format where that works.
    If you need to do other things, such as compare them to today's date, or see the difference between two of your rows in days, then you have to convert them to DATEs. (There's no point in converting them to NUMBERs).
    A new data type, TIMESTAMP, which handles fractions of a second, was introduced in Oracle 9.
    Since you're using Oracle 8 (according to your subject line), you either have to
    (1) ignore the microseconds, or
    (2) use a separate NUMBER column for the microseconds.
    Either way, use TO_DATE to convert the first 14 characters to a DATE:
    TO_DATE ( SUBSTR (txt, 1, 14)
            , 'YYYYMMDDHH24MISS'
            )where txt is your CHAR column.
    To convert the microseconds to a number (between 0 and 999999):
    TO_NUMBER (SUBSTR (txt, 15))

  • Datechooser display current date in YYYY/MM/DD format on init

    I have two date fields. I'd like one date chooser to display
    the current date on creation complete and the other should display
    the 30 days after the current date.
    The format needs to be YYYY/MM/DD.
    I'm currently getting a the current date in a var called
    currentDate but it returns at 11 Dec 2008.
    Thanks in advance.
    I

    Thanks,
    I am using : <mx:DateField id="effective_date"
    formatString="YYYY/MM/DD"
    text="{dgMessages.selectedItem.effective_date}" showToday="true"
    enabled="true"/>
    so after the user chooses a dates everything is fine.
    The customer wants todays date to already be populated in the
    datefield when the application loads and that's where I have my
    problem.
    I get my current date:
    var currentDate:Date = new Date();
    but I need to format that date from 12 Dec 2008 to 12/12/2008
    and create another date var called endDate adding 60 days.
    I assume I must convert this vars to strings since I get an
    error when attempting to display them in the datafield.
    I hope I explained that well enough.

  • Trouble entering dates in YYYY-MM-DD format

    On my system I have set the iCal date format to the correct Canadian ISO 8601 YYYY-MM-DD format for Canada. However when typing in dates (such as birthdates) the numbers do not go in correctly, presumably due to some internal edit process that does not accept birthdates like 1978. After trying several times it finally goes in. Has anyone else had this issue?

    Setting my date preference in System Preferences, International, Date formats to the correct yyyy-mm-dd seems to have solved the input problem in iCal. Problem solved.

  • Problem in converting the String to Date with time zone GMT

    Hi,
    When I tried to convert the string 12/05/2009 to Date, the time zone is set to BST.On the other hand, for the date 12/12/2009, the time zone is set to GMT. What should I do to get the time zone as GMT all the time.?
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    String dateString = "12/05/2009";
    System.out.println(myDate.toString());

    I think you are all missing the point. java.util.Date objects always alway always store the date as the number of milliseconds since 1/1/1970 UTC so the only TimeZone they have its the implicit UTC. When you use the Date.toString() method the toString() method gets the default time zone from your environment and formats the data accordingly. This means that the same Date object will, by default, produce a different result for France and Australia and the US.
    So, if you have the date "12/5/2009" as a String then to convert it to a java.util.Date you must specify what TimeZone is implied. If it is your system time zone then you can just create a SimpleDateFormat object with the correct format and then use the parse() method to create the java.util.Date object and this will automatically be converted to UTC. If the date String represents some other time zone then you must explicitly set the time zone of the SimpleDateFormat object before parsing the string.
    The same approach applies when converting a java.util.Date object to a String. If you want anything other than your system time zone then you must explicitly tell the SimpleDateFormat what time zone you want the result formatted for.

  • Runtime conversion of a string value to a primitive data type in java

    can anyone of you give me an idea to convert a string value to a primitive data type during run time...i have the value and the type to which it has to be converted as String values...do you have any idea ,...pls share

    String recvalvalue = inputval;
                    String recvartype = inputtype;
                   if (recvartype.equals("int")){
                   value0 = Integer.parseInt(recvalvalue);
             else
             if (recvartype.equals("double")){
                    value1  = Double.parseDouble(recvalvalue);
             else
             if(recvartype.equals("float")){
              value2 = Float.parseFloat(recvalvalue);
             else
             if(recvartype.equals("Boolean")){
              value3 = Boolean.parseBoolean(recvalvalue);
             else
             if(recvartype.equals("char")){
               value4 = (char)recvalvalue.charAt(0);
            else
            if(recvartype.equals("String")){
              value5 = recvalvalue;
             else
             if(recvartype.equals("byte")){
               value6 = Byte.parseByte(recvalvalue);
                  //listA.add(6, value6);
                  //     listA.g = value6;
             else
              if(recvartype.equals("long")){
               value7 = Long.parseLong(recvalvalue);
             else
              if(recvartype.equals("short")){
              value8 = Short.parseShort(recvalvalue);
             } yes i can do this but the resultant value has to be assigned to a variable of a specific type which is here recvartype .....it has to be done dynamically automatically..if we know what type of data is that we can convert and assign to the type but we donot know when we run the program as the program will be supllied by someone and has to be executed

  • How to parse system date to return Date and in yyyy-MM-dd format?

    DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again it is converted into dfault format i.e. 21 Jan 00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and again to return date.
    Can anybody tell me how to do this?

    DateFormat dateFormat = new SimpleDateFormat
    ("yyyy-MM-dd");
    java.util.Date date = new java.util.Date ();
    String dateStr = dateFormat.format (date);
    try{
    Date date2 = dateFormat.parse (dateStr);
    }catch(ParseException pe){
    pe.printStackTrace();
    Actually, After parsing the date from string, again
    it is converted into dfault format i.e. 21 Jan
    00.00.00 etc...
    But I want this parsing date in yyyy-MM-dd format and
    again to return date.
    Can anybody tell me how to do this?A Date object does not have a format, it represents a moment in time. You can use SimpleDateFormat to return a String representing that moment in time in many formats - this does not change the Date object to have that format (which it cannot since it does not contain a format).

  • In PDF to Excel conversion dates like 03/12/15 convert to Dec 3rd 2015 not the correct date of Mar 12th 2015 whereas date 03/13/2015 converts correctly as March 13th 2015

    In PDF to Excel conversion dates like 03/12/15 convert to Dec 3rd 2015 not the correct date of Mar 12th 2015 whereas date 03/13/2015 converts correctly as March 13th 2015

    Hi DirTech,
    Are both of these dates in the same Excel file? If they're in different files, are you choosing the same language for OCR (optical character recognition)?
    If they are in the same PDF file, how was that PDF file created? Was it created from a third-party application (rather than an Adobe application)? If it was created by a third-party application, it could be that it wasn't written to spec, and that's why you're seeing some oddities in the PDF > Excel conversion.  (See Will Adobe ExportPDF convert both text and form... | Adobe Community.)
    Best,
    Sara

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

Maybe you are looking for