How to get current date in a specified format ?

Hi,
I want to get the current date (java.util.Date()) in the format yyyy-MM-dd HH:mm:ss.
Can you please tell me as to how to get that ?
Regards

I have used the same and the code looks like this. But i am getting java.text.ParseException : UnParseable Date: "Fri Jul 11 13:29:43 CDT 2003"
The Code is :
java.util.Date sysDate = new java.util.Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formatted_date = df.format(sysDate);
It is erroring out in the last statement !!

Similar Messages

  • How to get current date for posting date

    hi,
    how to get current date for posting date ? any sample code ?
    Thanks

    Hi......
    Use
    Select getdate()
    for current date.......
    Regards,
    Rahul

  • How to get the Date in a particular format?

    Hi,
    How to get the Date in the below format? I will be passing the year in my method..
    2/10/2003 9:46:52 PM
    D/M/YYYY H:M:S A
    public Date getDate (String year) {
    Here i want to get the Date in this format
    2/10/<Passed Year> 9:46:52 PM
    Thanks

    This is my code
    public static Date getCalendar(Calendar calendar,int getYear) {
    String      formatted_date="";
         int year = getYear;
         int month = calendar.get(Calendar.MONTH+1);
         int day = calendar.get(Calendar.DATE);
         int hour = calendar.get(Calendar.HOUR);
         int min = calendar.get(Calendar.MINUTE);
         int sec = calendar.get(Calendar.SECOND);
         int am_pm =calendar.get(Calendar.AM_PM);
         formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
         System.out.println("formatted_date is "+formatted_date);     
         o/p : formatted_date is 1/4/2006 1:44:21 PM
         SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    //     DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
         Date passdate = new Date();
         try {
              passdate = dateFormat.parse(formatted_date);
         } catch (ParseException e) {
              System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
              System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
    o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
         return passdate;
    Expected O/P is 3/1/2006 1:44:12 PM
         }

  • How to Get Current Date from MS Access in a Select Statement

    From a java method, I want to use JDBC to get the current date from MS Access. In Oracle I would do "select sysdate from dual", but I can't figure out how to do it in MS Access. Here are some of my attempts. I have a table in my Access db called PARM.
    //        String sql = "SELECT '0', NOW() FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT DATE() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW()"; 
    //StringIndexOutOfBoundsException: String index out of range: -1
    //        String sql = "select { fn now() } from parm";
            String sql = "SELECT Date()";
    //java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                return rs.getString(1);
            } else {
                   return null;
              }

    Why are you getting it as a String? You should be getting it as a timestamp.
    Although getString works for me too. There is something else wrong that you haven't shown.
    Here is some shoddy, but simple, test code that demonstrates it working.
    import java.sql.*;
    public class Test{
      public static void main(String args[])throws Exception{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection c = DriverManager.getConnection("jdbc:odbc:stats");
        Statement s = c.createStatement();
        ResultSet rs = s.executeQuery("SELECT NOW()");
        while(rs.next()){
          System.out.println(rs.getTimestamp(1));     
        rs.close();
        s.close();
        c.close();
    }

  • Pages - How to get current date when opening a template!

    I have a stationery template with the date on itl When the template opens can I get it to display the current date.. It so how is that done.

    Yes, and the worst:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=424&sid=ba144f60f149 4f75c94316b0c7fbff2b&mforum=iworktipsntrick
    If you had Pages previously it should be in your Applications > iWork folder.
    Peter

  • How do get current date/time in GMT?

    Is there any way to get the current date and time in GMT (while my current locale is not GMT)?
    In Java I can do this:
    long currenttime = System.currentTimeMillis();
    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
    df.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    java.util.Date date = new java.util.Date();
    date.setTime(currenttime);But, there seems to be no way to do the equivalent in BPEL in SOA Suite.
    I did some research and I think I could appy the XPath 2.0 function adjust-dateTime-to-timezone() to the current time, but that function is not available.
    Using SOA SUite 11.1.13.0.
    THanks.

    have you tried changing the stylesheet version in the xsl to 2.0 and then try the function again ?
    by changing this version it was possible to use newer functions, which weren't available in the designer

  • How to get GML data in LAT/LONG format rather than LONG/LAT format

    I want to generate GML from my spatial data but sdo_util.to_Gmlgeometry extracts data in LONG/LAT format where as I need it in LAT/LONG format.
    Is there an easy way to extract data in LAT/LONG format otehr than parsing the gml and then switching the Lat and long.

    Hi,
    I think it would have to do how you store your geometries, you might need a transformation before, notice the srsName from the resulting query:
    SELECT TO_CHAR(SDO_UTIL.TO_GMLGEOMETRY(MDSYS.SDO_GEOMETRY(2001, 8307, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), MDSYS.SDO_ORDINATE_ARRAY(170.5,-43.5))))
    from dual
    -- Result:
    <gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="." cs="," ts=" ">170.5,-43.5 </gml:coordinates></gml:Point>
    So without a transformation I would say it would be hard to get:
    http://trac.osgeo.org/gdal/wiki/rfc20_srs_axes
    If I come across a simple solution (without some fancy manipulation of the ordinates on a custom function/package) I will post it.
    Cheers

  • How to get current row data in table control

    Hi , expert ,
       I am professional in oracle ,  but  now I am a new guy in SAP ABAP .
    I  have a question in UI
    How to get current row data and click pushbutton  in table control  to open next screen ?
    I want to get the current data and open next screen to carry out detail detail .
    Thansk for all your suggestion .

    GET CURSOR LINE SY-CUROW .
      READ TABLE internal_table index SY-CUROW.

  • How to get current time and date??

    How to get current time and date from my PC time and date to the java application??
    i use java.util.* package but got error, that is:
    - java.util.* and java.sql.* class are match
    - abstract class cannot be instantiated
    so what can i do, pls guide...thanks...

    There is a method in the System class that will return the current system time. You could also instantiate a Date, Time, Timestamp, or Calendar object, all of which get created with the system time by default.
    Don't import *. Import the specific classes you need.
    Next time, post the actual text of the exceptions/compile errors. If you make people guess, most just won't bother.

  • How to get the date starting from 1 to the current date from the system dat

    Dear all,
    Please tell me how to get the date starting from 1 based on the system date
    and it should come with respect of time also.
    example.
    suppose today is 6 Dec, 2006
    so ABAP report should find the 1 dec. 2006.
    Please help me as soon as possible.
    Regards,

    concatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
    or yo ucan use the fm:
    HR_JP_MONTH_BEGIN_END_DATE
    usage:
        call function 'HR_JP_MONTH_BEGIN_END_DATE'
             exporting
                  iv_date             = sy-datum
             importing
                  ev_month_begin_date = gv_begda
                  ev_month_end_date   = gv_endda.
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • How does BR get current date, user, and associate member with Attribute Dim

    I need use Business rules or Calc script to implement following functions:
    1. Get current date and the name of user who is running the BR and save the information to cube.
    I don't find any functions to get current date and users.
    Also, since text and date is store in relational database and essbase cube only stores the index, it looks that the value can't be changed or stored by using "==" directly, is there any function to change value of members with Text or Date types in BR/Calc script?
    2. End users select attribute value (via smart list) of products or projects(Sparse dimensions) in data form, run BR to update the association of these members with attribute dimension.
    I don't find any functions to change the attribute association in BR/Calc, is there any CDF (Custom Defined Function) that can do it?
    Thanks!

    Hi,
    For the date functionality, check out the post below.
    Re: Days behaviour between two dates
    As for the username, there is a little tricky way that requires an unused or a new dimension along with a smart list of user names. It's also possible to capture the user name from the cookies and pass it on to the form. The latter is possible through validatedata.js however requires hefty coding here and there.
    As for the attributes, it's not possible to update metadata through business rule. So no luck in there.
    Cheers,
    Alp

  • How to get purchasing data from SAP R/3 to OWB (Oracle warehouse builder).

    Hi,
    My name is Pavan Tata. I work as a SAP BW developer. Here is the situation at my client place. Client decided to retire BW system and wants to replace with OWB(Oracle warehouse). In all this currently we have purhchasing application in BW production system and wants to move this application to OWB for the same type of reporting what they are getting currently.
    Here is my question:
    How to get purchasing data from SAP R/3 to OWB(Warehouse) with initial full loads and deltas mechanism in the same way as we do in BW.
    Please help on this, also send me any documentation about this if you have.
    Thanks,
    Pavan.

    Hello,
    here is a short report which converts S012 entries to strings with separator semicolon. Perhaps this will help you?
    Regards
    Walter Habich
    REPORT habitest2 LINE-SIZE 255.
    TYPES:
      strtab_t TYPE TABLE OF string.
    CONSTANTS:
      separator VALUE ';'.
    DATA:
      it_s012 LIKE s012 OCCURS 0,
      wa_s012 LIKE s012,
      strtab TYPE strtab_t,
      strele TYPE string.
    SELECT * FROM s012 INTO TABLE it_s012 UP TO 100 ROWS.
    PERFORM data_to_string
      TABLES
        strtab
      USING
        'S012'. "requires it_s012 and wa_s012
    LOOP AT strtab INTO strele.
      WRITE: / strele.
    ENDLOOP.
    *&      Form  data_to_string
    FORM data_to_string TABLES strtab TYPE strtab_t
                        USING  ittab TYPE any.
      DATA:
        h_zaehler TYPE i,
        line_str TYPE string,
        l_tabellenname(10) TYPE c,
        l_arbeitsbereichsname(10) TYPE c,
        h_string TYPE string,
        h_char(255) TYPE c.
      FIELD-SYMBOLS: <l_tabelle> TYPE ANY TABLE,
                     <l_arbeits> TYPE ANY,
                     <feldzeiger> TYPE ANY.
      CLEAR strtab.
      CONCATENATE 'IT_' ittab INTO l_tabellenname.
      ASSIGN (l_tabellenname) TO <l_tabelle>.
      CONCATENATE 'WA_' ittab INTO l_arbeitsbereichsname.
      ASSIGN (l_arbeitsbereichsname) TO <l_arbeits>.
      LOOP AT <l_tabelle> INTO <l_arbeits>.
        CLEAR: h_zaehler, line_str.
        line_str = ittab.
        DO.
          ADD 1 TO h_zaehler.
          ASSIGN COMPONENT h_zaehler OF
            STRUCTURE <l_arbeits> TO <feldzeiger>.
          IF sy-subrc <> 0. EXIT. ENDIF.
          WRITE <feldzeiger> TO h_char LEFT-JUSTIFIED.          "#EC *
          h_string = h_char.
          CONCATENATE line_str separator h_string INTO line_str.
        ENDDO.
        APPEND line_str TO strtab.
      ENDLOOP.
    ENDFORM.                    "data_to_string

  • How to get communication data in CRM 7.0

    In CRM 7.0 with CCS active.
    How to get communication data (Current phone #) that is presently active while creating Interaction Record or during account confirmation.
    Thanks,
    Nilesh P.

    Hi,
    This problem is related to IC and not related to Marketing Campaign.
    At this movement I hv resolved this problem by storing phone # in memory variable by some other way.
    But I would be more interested to know Communication Data in 'Context area' of IC.
    Thanks & Regards,
    Nilesh P.

  • Get  current date and time

    hello.
    How can I get current date and time in JAVA?
    Thanks.

    Sorry, I mean:
    how can I get the value of DATE, MONTH, and YEAR of the
    current date?
         Date date = new Date();
         System.out.println(date);

  • How to view current  date and time on SAP screen

    Hi Everybody,
    How to view current  date and time on SAP screen .I have set time zone in T-code STZAC.now iam getting correct date n time in my tranctions but i want to check without any tractions
    Plz repay,Regards,
    Sadik.

    Hi,
    You can check the time by running a report .
    It will show the database and central instance time : Report name :rsdbtime
    Thanks and Regards
    Vijay kumar G
    Edited by: vijay kumar gopal on Mar 4, 2008 1:09 PM

Maybe you are looking for

  • Custom Page size needed 24x24

    I create Real Estate signs and use Pages. So I need a 24x24 inch "paper" to send to my printer who needs the artwork in a PDF. BUT there is no option anymore of a custom size or I can't figure it out... HELP...

  • Images will not display on Export to PDF

    I have a BOXi Web Intelligence Document that displays two images that are 7kb each. The Text for one of the objects is set to: http://cpolrhp.belvoir.army.mil/eur/images/CHRA_Logo.gif That object is set to read the text as: Image URL The images displ

  • How to handle form with more than one page in struts

    Hai, i have more than one page in my struts web apps. each page has a form & i have submit button @ last page. I navigate between these pages using titles. data has to exist when i come back from another page(i.e i am in page1 i have some fields call

  • Wave forms won't display in timeline

    Hello: I just upgraded to FCP version 5.1 from version 4.5 on my G4 powerbook. The audio plays fine, but for some reason I can't get the waveforms to show up in the timeline. All I see are the red lines and the small "x" symbols on each audio clip. W

  • Cracked Iphone 5 help!

    I cracked the front of my iphone 5. I have only had the phone for 5 months. What do I do? Is it under warranty or should I get apple care to replace the phone or do I pay the $229 at the apple store?