How to convert string into date datatype

hi! there
i've a date in string format like MM/dd/yyyy
eg:String sDate = "01/30/2002";
and i want to convert this string format into java date format
same as 01/30/2002 only
when i write like this
SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yyyy");
          String sDate = "1/11/2002";
          java.util.Date oDate = formatter.parse(sDate);
i'm getting the output
Fri Jan 11 00:00:00 GMT+05:30 2002
i just want the out put like 01/30/2002
plz,help me

Hi,
Just use back the SimpleDateFormat object you defined.
String myDateInStr = formatter.format(oDate);
this will format a java.util.Date object to a string representation according to the format you specified in the instantiation of SimpleDateFormat object.

Similar Messages

  • How to convert string into date

    Hi all,
    I m new to JDeveloper
    I m taking the date as a string then passing it as a string in the method.
    I want to convert tht string into the date of format (DD-MON-YYYY) or any other format
    require yur assistance in this job.
    THANKXX in advance
    ankit

    Is this what you are looking for:
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MMMMM-YYYY");          
    java.util.Date date1 = null;
    try
       date1 = formatter.parse("Thu Jun 3 09:09:30 2004");
    catch(Exception e)
       e.printStackTrace();
    System.out.println("Date1 in millis : " + date1.getTime());
    System.out.println("Date1 in string : " + date1);
    java.util.Date date2 = new java.util.Date(date1.getTime());
    System.out.println("Date2 in string : " + date2);or look at http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html for more options

  • How to convert files into DAT?

    Does anyone know how to convert files into DAT? Not The other way around please.

    This might do it:
    http://www.videoconverterformac.com/dat-converter-for-mac.html
    but can't imagine why you would want to!

  • How to convert Milliseconds into Date format

    Hi all,
    I am getting the output of a variable in milliseconds format, how can I convert it into date format
    For ex: I am getting input variable as 1366664691000 and I need to convert it to April 22, 2013 5:04:51 PM EDT ( or of SOA format). is there any function for this in XSL or XPath?
    Thanks,

    It is working fine if i test it in provided site...
    But it is returning "-1366664691001", If i am running it in EM. This is the code in my xsl
    <?xml version="1.0" encoding="UTF-8" ?>
    <?oracle-xsl-mapper
    <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
    <mapSources>
    <source type="WSDL">
    <schema location="../JavaProcess.wsdl"/>
    <rootElement name="process" namespace="http://xmlns.oracle.com/SampleApplication/JavaEmbeddingActivity/JavaProcess"/>
    </source>
    </mapSources>
    <mapTargets>
    <target type="WSDL">
    <schema location="../JavaProcess.wsdl"/>
    <rootElement name="processResponse" namespace="http://xmlns.oracle.com/SampleApplication/JavaEmbeddingActivity/JavaProcess"/>
    </target>
    </mapTargets>
    <!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.4.0(build 110106.1932.5682) AT [TUE MAY 07 10:21:02 EDT 2013]. -->
    ?>
    <xsl:stylesheet version="1.0"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
    xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
    xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:med="http://schemas.oracle.com/mediator/xpath"
    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
    xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:bpmn="http://schemas.oracle.com/bpm/xpath"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:client="client"
    exclude-result-prefixes="xsi xsl bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref bpmn ora socket ldap">
    <xsl:template match="/">
    <xsl:variable name="lastMTime" select="1366664691000"/>
    <xsl:copy-of select="$lastMTime"/>
    <client:processResponse>
    <client:result>
    <xsl:value-of select='xsd:dateTime("1970-01-01T00:00:00") + $lastMTime * xsd:dayTimeDuration("PT0.001S")'/>
    </client:result>
    </client:processResponse>
    </xsl:template>
    </xsl:stylesheet>

  • How to convert string to date based on regional settings

    How can I convert a simple string ("01/04/2003" or "01-04-2003" or "01 April 2003") to a date formatted according to the regional settings?
    For example, if my regional settings is set to "dd mm yyyy", the result will be 01 as dd, 04 as mm and 2003 as yyyy.
    If the regional settings is set to "mm dd yyyy", the result will be 01 as mm, 04 as dd and 2003 as yyyy
    Hope someone can help.
    Thanks in advance.

    I think you have the wrong idea about how Oracle stores dates. Any date in Oracle is stored in a seven byte representation
    SQL> SELECT DUMP(last_hire_dt) FROM emp_t WHERE rownum = 1;
    DUMP(LAST_HIRE_DT)
    Typ=12 Len=7: 119,191,5,6,1,1,1This storage is independent of the NLS date settings. The TO_CHAR(dt,format) and TO_DATE(str,format) functions serve to translate this internal representation into the external presentation supplied by the format. So, if you need to translate a date that is contained in a string into an Oracle date datatype, you need to tell Oracle how to parse the string.
    If the string format matches your NLS_DATE_FORMAT parameter, Oracle will do this implicitly. Otherwise, you need to tell Oracle explicitly which piece is which. For example, is the string (ignoring the problem of two digit years :-) ):
    '02/01/03'
    Feb. 1, 2003, Jan. 2, 2003, or Mar. 1, 2002? If your date format is dd-MON-yyyy as mine is, then:
    SQL> SELECT TO_DATE('02/01/03') FROM dual;
    SELECT TO_DATE('02/01/03') FROM dual
    ERROR at line 1:
    ORA-01843: not a valid month
    SQL> SELECT TO_DATE('30-Jan-2003') FROM dual;
    TO_DATE('30
    30-JAN-2003HTH
    John

  • How to convert String to date ? - MS access

    I want to convert a string "10-10-08" [ MM-dd-yy ] into date type in same format to use that in query statement [MS Access].
    In table , I am using field called "date" with "MM-dd-yy" format.
    Example:
    <%@ page import= "java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat"%>
    <%@ page import="java.util.Date"%>
    <%
    String d="10-9-08";
         SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yy");
              Date date = dateFormat.parse(d);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");
         Statement st = con.createStatement();
    ResultSet rs=st.executeQuery("Select * from datacollectdb where date='"+date+"'");
    %>
    I am getting "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    " error.
    How to use the string "10-10-08" in where statement?

    sangee wrote:
    I want to convert a string "10-10-08" [ MM-dd-yy ] into date type in same format to use that in query statement [MS Access].
    In table , I am using field called "date" with "MM-dd-yy" format.I think a column named "date" is a very bad idea. Not just because "date" is a keyword. It's not very self-describing. How about "birth_date" or "hire_date" or "went_on_my_first_date"?
    Example:Scriptlets? There's your second mistake.
    <%@ page import= "java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat"%>
    <%@ page import="java.util.Date"%>
    <%
    String d="10-9-08";The way you're doing things, "2-40-99" is a valid date. Is that what you want?
         SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yy");
              Date date = dateFormat.parse(d);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");Wrong again. Better to use a PreparedStatement and bind that Date.
         Statement st = con.createStatement();
    ResultSet rs=st.executeQuery("Select * from datacollectdb where date='"+date+"'");
    %>
    I am getting "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    " error.
    How to use the string "10-10-08" in where statement?Use PreparedStatement and bind.
    Your JSP should not be getting a database connection. Pool it.
    Your code is wrong on every level. You don't close resources, you don't separate you app into layers, your database code is not in a POJO. I'd recommend that you throw this away and start again.
    %

  • How to convert varchar to date datatype while insert or update in table

    Hai All
    I need to convert to varchar to date.
    I have two Tables T1,T2
    T1 Structure
    Code varchar
    Time varchar
    Date varchar
    T2 Structure
    Empname var
    Empcode var
    Intime date
    Outtime date
    Intrin date
    Introut date
    Att_date
    Now i need to move Time form T1 to T2 Intime,outtime,intrin,introut according some condition
    So now i need to convert Varchar to Date while insert or update
    I have tried something
    Insert into T1 (code,intime,att_date)values
    (code,To_date(Date||time,'dd-mon-yyyy hh24mi'),att_date);
    OR While update
    Update T2 set Outtime=To_date(Date||time,'dd-mon-yyyy hh24mi') where...
    I got an error Ora-01861
    Regards
    Srikkanth.M

    You didn't show any example of your date or time values, butyou might need to add a space between them, like
    To_date(Date || ' ' || time,'dd-mon-yyyy hh24mi')

  • How to converts string into numbers

    As a beginer now i am asking the above question?
    now i am working with XCode 4.3

    I responded to you here > How to convert pages document into...: Apple Support Communities
    Please do not start duplicate topics 

  • Problem in converting character into date datatype

    Hi Experts,
    I am developing an oracle function in which I am passing an input in varchar2 and I want the return that varchar value in date datatype.
    We are using to_date(to_char(:input,'YYYY-MON-DD')) but this is giving the output in simple format which is defined by the oracle i.e. 'MM-DD-YYYY'.
    We need the output in 'YYYY-MON-DD' and that too in date datatype.
    I guess you understand my question.
    Waiting for your response.
    Thanks

    i think you understand this :
    SQL>  select to_date('2013-06-13','yyyy-mm-dd') from dual;
    TO_DATE('
    13-JUN-13
    SQL> alter session set nls_date_format = 'yyyy-mm-dd';
    Session altered.
    SQL> select to_date('2013-06-13','yyyy-mm-dd') d  from dual;
    D
    2013-06-13
    SQL> alter session set nls_date_format = 'dd.mm.yyyy';
    Session altered.
    SQL> select to_date('2013-06-13','yyyy-mm-dd') d  from dual;
    D
    13.06.2013
    SQL> exit
    but if you have windows except alter session set you will need to see REGEDIT and Regional parameters.

  • Converting string into date

    How can I convert a string 07-27-2001 in a date.

    How can I convert a string 07-27-2001 in a date.
    one of the solutions might be --
    SimpleDateFormat format = new SimpleDateFormat ("MM-dd-yyyy");
    Date date = format.parse("07-27-2001");

  • How to convert string to date

    HI Everyone,
    i am trying to convert a date which is in string format to a date format...but i am having this error
    javax.servlet.ServletException: Unparseable date: "2004-05-03"
    Can anyone help?
    Here is a piece of code :-
    SimpleDateFormat formatter= new SimpleDateFormat ("yyyy-mm-dd");
    Date today = formatter.parse(fulldate);

    You need to change your formatting string to: "yyyy-MM-dd" Lower case 'm' is for minutes...

  • How to convert string to date format?

    Hi All,
    String is in following format: 2006-12-07 i.e yyyy-mm-dd
    I want it in 07.12.2006 date format.
    which function module should i used to convert it?
    Regards,
    Nilima

    an other way to do this :
    Code
    DATA :
    ld_text(20) TYPE c,
    ld_date TYPE datum.
    ld_text = '2006-12-07'.
    REPLACE ALL OCCURENCES OF '-' IN ld_text WITH ''.
    WRITE ld_text TO ld_date.
    WRITE ld_date.

  • How to convert strings into character type?

    I have created a function module which will display the attributes of the fields of the structure/table by using "DESCRIBE FIELD" command. The problem is that it supports only character-type data objects and the program goes into dump
    if the structure contain any string type.

    Please have a look at class CL_ABAP_DATADESCR. Using this instances of this class should provide all information needed...
    Reward points, if reply is applicable

  • How to convert string to date and check date difference in filter clause | error in filter clause

    Hi All,
    I have a requirement where i want to stop replicat if particular record is encountered on target.
    if PARAMETER_CODE="APPLDATE" and difference between parameter_value is 1 then replicat should stop.
    the code i am using is,
    map schema.src_tablename , target schema.trg_tablename, &
    WHERE(PARAMETER_CODE="APPLDATE"), &
    filter (on updates, (@to_date(before.PARAMETER_VALUE,'dd/mm/yyyy hh24:mi:ss')) - (@to_date(PARAMETER_VALUE,'dd/mm/yyyy hh24:mi:ss')) =1), &
    EVENTACTIONS(STOP);
    Replicat process abends with error in filter clause.
    Concern here is the parameter_value column is in varchar2 and not in date. (if its date than filter (on updates, @datediff ("DD",before.PARAMETER_VALUE, PARAMETER_VALUE) =1)  is working correctly). I need to stop replicat when date(in varchar2 format) gets incremented by 1.
    Please do help in solving the issue.
    Thanks,
    TrushB.

    Dear all,
    Please do update... how to covert a varchar2 to date in GG.

  • : how to convert string into uppercase string in java

    iam having string in lower case i need to convert it to uppercase using java.please help me

    s = s.toUpperCase ();See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html.

Maybe you are looking for

  • How do I delete my uploaded files? I am on an Ipad.

    How do i delete my uploaded files? There is no trash button

  • Partner S is not defined

    Hi. I need to create a new partner function but link it to a position ( type S). When I select the "S" in the dropdown and enter, it comes up with the following error message: "Partner S not defined". Is there config or table entries that i have to m

  • FINSTA inbound idocs - "Error during insert in table FEBKO"

    Can anyone tell me , y this error comes? I am using File to IDOC scenario. I need to update bank statement. It can be given in multiple pages. I need to update depending upon the date as well as its page number. Sometimes I get this error. Can anyone

  • Printing material-documents without flag (parameter NDR)

    Hello everybody, I've got a question regarding printouts of material-documents. Normally the printout is done via condition-technique. Now my customer asks for a printout even if the flag for the printing is NOT set (Parameter NDR) in the document-he

  • How to prepare for OCP DBA exams

    I am a graduate of geology from the University of Ibadan, Nigeria. I got intereted in OCP DBA when i saw Jason Couchman book 'Oracle8i certified professional DBA certificaton Exam Guide' with a friend. i never had any experience in database before bu