Facing problem in converting string to date using getOANLSServices()

I am trying to set a value for date field in my vo and trying to insert into the table.
In controller I am getting the String which has a date:
ex: String date="01-NOV-2007";
while setting into the row I need to convert into Date but it is returning null.
The below code I used
to convert into date :
Date dt = new Date(getOADBTransaction().getOANLSServices().stringToDate(date));
But this dt is returning a null value is there any solution please advise me.
Regards!
Smarajeet

Smarajeet ,
See this thread, in one of my replies i have mentioned how to convert string to java.sql.date.You can use the same for oracle.jbo.domain.Date.
urgent!How to set the default selected date for an OAMessageDateFieldBean
--Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Facing problem during uploadation of Routing data using CA01-BDC - URGENT

    Dear All,
    When I am trying to upload Routing data using CA01 in the Table Control scenario, then I am facing problem as my last 2 records are not getting uploaded from my Test file.
    For example, I am having 47 records in my Test File and after setting ‘Default size’ parameters (to avoid screen resolution problem)
    I have 15 table control line items data per page. The Page down logic ('=P+') is working fine, but my below BDC code failed to take
    the remainder last 2 records from the Test File.
    Analysis: When I am running my “Call Transaction” bdc in foreground, then the 1st page down occurs after 15th record, 2nd page down occurs after 29th record( as in Table Control 1st page’s 15th record is coming on the Top of 2nd page). 3rd page down occurs after 43rd record
    (as 2nd page’s 29th record is coming on the top of 3rd page). In the 4th Table Control Page 43rd record of previous page is coming on top, and then it’s taking 44th & 45th records from the Test File and then it is triggering SAVE (=BU). Thus, our last 2 records
    (i.e. 46th, 47th record) are not getting uploaded in the routing screen from our Test File.
    If anybody has encountered this scenario previously, please help me URGENTLY in fixing the bugs here. It’s VERY, VERY URGENT…
    FYI. For others 45 successful records already uploaded, all the screen fields values are coming properly in the routing screen, and here there is no issue.
    Thanks very much…
    Thanks & Regards
    Sudipta – Project Lead
    Volvo Client Location
    I am pasting my BDC source code below:
    REPORT ZRT1_UPLOAD_CA01_F
                           NO STANDARD PAGE HEADING
                           LINE-SIZE 255.
                            I N C L U D E S                              *
    Include for Data Declarations
    INCLUDE zrout_top.
    Include for Forms
    INCLUDE zrout_form.
    INCLUDE zrout_include_f_ca01.
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    Attaching F4 help with filename
      PERFORM F1001_GET_F4.
               S T A R T   -   O F  -  S E L E C T I O N                 *
    START-OF-SELECTION.
    Perform to read the input file
      PERFORM f_read_file.
    Perform to fill the BDC data
      PERFORM f_fill_bdctab.
                   E N D   -   O F  -  S E L E C T I O N                 *
    END-OF-SELECTION.
      FREE: i_bdcdata,
            i_messtab,
            i_record.
    x----
    *&  Include           ZROUT_TOP                                        *
                      D A T A B A S E    T A B L E S                     *
    TABLES: t100.          "Messages
                    D A T A    D E C L A R A T I O N S                   *
    T A B L E    T Y P E S *****************************
    For input data
    TYPES: BEGIN OF ty_record,
            matnr(18),  "Material Number
            werks(4),   "Plant
            verwe(3),   "Usage
            statu(3),   "Status
            arbpl(8),   "Work Center
            steus(4),   "Control Key
            ltxa1(40),  "Description of Operation
            bmsch(13),  "Base Quantity
            meinh(3),   "Unit of Measure
            vgw01(11),  "Machine
            vge01(3),   "Unit of measure of activity
          END OF ty_record.
    I N T E R N A L    T A B L E S ***********************
    Internal Table for input file name
    DATA: i_file_tab  TYPE STANDARD TABLE OF sdokpath   INITIAL SIZE 0.
    Internal Table for BDC Data
    DATA: i_bdcdata   TYPE STANDARD TABLE OF bdcdata    INITIAL SIZE 0.
    Internal Table for BDC Messages
    DATA: i_messtab   TYPE STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0.
    Internal Table for Input file
    DATA: i_record TYPE STANDARD TABLE OF ty_record INITIAL SIZE 0.
    W O R K      A R E A S *************************
    Work Area for input file name
    DATA: wa_file_tab LIKE sdokpath.
    Work Area for BDC Data
    DATA: wa_bdcdata LIKE bdcdata.
    Work Area for BDC Messages
    DATA: wa_messtab LIKE bdcmsgcoll.
    Work Area for Input file
    DATA: wa_record TYPE ty_record.
    V A R I A B L E S ****************************
    DATA: v_filename TYPE string,
          v_fnam(40) TYPE c.
    DATA: wa_opt TYPE ctu_params.
    C O N S T A N T S ***************************
    CONSTANTS: c_werks TYPE rc27m-werks VALUE 'tp',
               c_steus TYPE plpod-steus VALUE 'PP01'.
    *Selection Screen.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:
              Input file name
                P_FILE TYPE rlgrap-filename OBLIGATORY. " DEFAULT 'C:\'.
    SELECTION-SCREEN END OF BLOCK B1.
    x----
    *&  Include           ZROUT_FORM                                       *
    *&      Form  f_fill_bdctab
          Form to fill the BDC Data
    FORM f_fill_bdctab.
      TABLES mapl.          "Assignment of Task Lists to Materials
      DATA: l_cnt_item(3)  TYPE n VALUE 1.    "Line item counter
      DATA: first(3)  TYPE n VALUE 16.    "Line item counter
      DATA: next(3)  TYPE n .    "Line item counter
      DATA: lin(3) TYPE n .    "Line item counter
      DATA: l_v_bmsch(13),   "Base qty
            l_v_meinh(3),    "Unit of Measure
            l_v_vgw01(11),   "Machine
            l_v_vgw02(11),   "Labour
            l_v_vge01(3).    "Unit of measure of activity
      DATA l_v_nextline TYPE sy-tabix.
      DATA wa_temp TYPE ty_record.
        Initialize Counter
          l_cnt_item = 1.
      SORT i_record BY matnr.
      LOOP AT i_record INTO wa_record.
    AT NEW matnr.
        REFRESH: i_bdcdata,
                 i_messtab.
        SET PARAMETER ID 'PLN' FIELD space.
        SET PARAMETER ID 'PAL' FIELD space.
        PERFORM f_bdc_dynpro      USING 'SAPLCPDI' '1010'.
        PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                        '/00'.
      Material Number
        PERFORM f_bdc_field       USING 'RC27M-MATNR'
                                        wa_record-matnr.
       Plant
        PERFORM f_bdc_field       USING 'RC27M-WERKS'
                                        c_werks.
        PERFORM f_bdc_field       USING 'RC271-PLNNR'
      Check if routing already exits for the material
        SELECT * FROM mapl
                      INTO mapl
                                WHERE matnr EQ wa_record-matnr
                                  AND werks EQ c_werks
                                  AND plnty EQ 'N'.
          IF sy-subrc EQ 0.
            PERFORM f_bdc_dynpro      USING 'SAPLCPDI' '1200'.
            PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                            '=ANLG  '.
          ENDIF.
        ENDSELECT.
        perform f_bdc_dynpro      USING 'SAPLCPDA' '1200'.
        perform f_bdc_field       USING 'BDC_OKCODE'
                                  '=VOUE'.
    Group Counter
        perform f_bdc_field       USING 'PLKOD-PLNAL'
      Usage
        PERFORM f_bdc_field       USING 'PLKOD-VERWE'
                                        '1'.
      Status
        PERFORM f_bdc_field       USING 'PLKOD-STATU'
                                        '4'.
    ENDAT.
        PERFORM f_bdc_dynpro      USING 'SAPLCPDI' '1400'.
      Check if page is full
        IF l_cnt_item EQ '16'.
        Page down
          PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                               '=P+'.
          l_cnt_item = 1.
    ELSE.
    PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
    ENDIF.
       CLEAR v_fnam.
      Populate item level details
    Work Center
        CONCATENATE 'PLPOD-ARBPL(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-arbpl.
      Control Key
        CONCATENATE 'PLPOD-STEUS(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        c_steus.
      Description of Operation
        CONCATENATE 'PLPOD-LTXA1(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-ltxa1.
      Base Quantity
        CONCATENATE 'PLPOD-BMSCH(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-bmsch.
      Unit of Measure
        CONCATENATE 'PLPOD-MEINH(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-meinh.
      Machine
        CONCATENATE 'PLPOD-VGW01(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-vgw01.
      Labour
       CONCATENATE 'PLPOD-VGW02(' l_cnt_item ')' INTO v_fnam.
       PERFORM f_bdc_field       USING v_fnam
                                       wa_record-vgw02.
      Unit of measure of activity
        CONCATENATE 'PLPOD-VGE01(' l_cnt_item ')' INTO v_fnam.
        PERFORM f_bdc_field       USING v_fnam
                                        wa_record-vge01.
          l_cnt_item = l_cnt_item + 1.
       CLEAR wa_record.
    AT END OF matnr.
         PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
          PERFORM f_bdc_field         USING 'BDC_OKCODE'
                                  '=BU'.
         wa_opt-DISMODE = 'A'.
         wa_opt-DEFSIZE = 'X'.
         wa_opt-UPDMODE = 'S'.
        PERFORM f_bdc_transaction USING 'CA01'.
       Initialize Counter
         l_cnt_item = 1.
    ENDAT.
      ENDLOOP.
    ENDFORM.                    " f_fill_bdctab
    x----
    *&  Include           ZROUT_INCLUDE_F_CA01                             *
    *&      Form  f_read_file
          Form to read the file from presentation server
    FORM f_read_file .
    To get the file name
      DATA l_v_file TYPE string.
    l_v_file = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename                = l_v_file
            filetype                = 'ASC'
            has_field_separator     = 'X'
          TABLES
            data_tab                = i_record
          EXCEPTIONS
            file_open_error         = 1
            file_read_error         = 2
            no_batch                = 3
            gui_refuse_filetransfer = 4
            invalid_type            = 5
            no_authority            = 6
            unknown_error           = 7
            bad_data_format         = 8
            header_not_allowed      = 9
            separator_not_allowed   = 10
            header_too_long         = 11
            unknown_dp_error        = 12
            access_denied           = 13
            dp_out_of_memory        = 14
            disk_full               = 15
            dp_timeout              = 16
            OTHERS                  = 17.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    ENDIF.
    ENDFORM.                    " f_read_file
    *&      Form  f_bdc_dynpro
          Form to populate BDC Tab for new screen
         -->fp_program   Screen program name
         -->fp_dynpro    Screen Number
           Start new screen                                              *
    FORM f_bdc_dynpro USING fp_program fp_dynpro.
      CLEAR wa_bdcdata.
      wa_bdcdata-program  = fp_program.
      wa_bdcdata-dynpro   = fp_dynpro.
      wa_bdcdata-dynbegin = 'X'.
      APPEND wa_bdcdata TO i_bdcdata.
    ENDFORM.                    "f_bdc_dynpro
    *&      Form  f_bdc_field
           Insert field                                                  *
    FORM f_bdc_field USING fp_fnam fp_fval.
      IF NOT fp_fval IS INITIAL.
        CLEAR wa_bdcdata.
        wa_bdcdata-fnam = fp_fnam.
        wa_bdcdata-fval = fp_fval.
        APPEND wa_bdcdata TO i_bdcdata.
      ENDIF.
    ENDFORM.                    "f_bdc_field
    *&      Form  f_bdc_transaction
          Call transaction and error handling
         -->fp_tcode   Transaction code
    FORM f_bdc_transaction  USING fp_tcode.
      DATA: l_mstring(480),
            l_color         TYPE i,
            l_mode          TYPE c.
      REFRESH i_messtab.
    CALL TRANSACTION fp_tcode USING i_bdcdata
                       OPTIONS FROM wa_opt
                       MESSAGES INTO i_messtab.
    Messages during upload
      LOOP AT i_messtab INTO wa_messtab.
        CASE wa_messtab-msgtyp.
          WHEN 'S'.
            l_color = 5.
          WHEN 'E'.
            l_color = 6.
          WHEN 'W'.
            l_color = 3.
        ENDCASE.
        FORMAT COLOR = l_color.
        SELECT SINGLE * FROM t100 WHERE sprsl = wa_messtab-msgspra
                                  AND   arbgb = wa_messtab-msgid
                                  AND   msgnr = wa_messtab-msgnr.
        IF sy-subrc = 0.
          l_mstring = t100-text.
          IF l_mstring CS '&1'.
            REPLACE '&1' WITH wa_messtab-msgv1 INTO l_mstring.
            REPLACE '&2' WITH wa_messtab-msgv2 INTO l_mstring.
            REPLACE '&3' WITH wa_messtab-msgv3 INTO l_mstring.
            REPLACE '&4' WITH wa_messtab-msgv4 INTO l_mstring.
          ELSE.
            REPLACE '&' WITH wa_messtab-msgv1 INTO l_mstring.
            REPLACE '&' WITH wa_messtab-msgv2 INTO l_mstring.
            REPLACE '&' WITH wa_messtab-msgv3 INTO l_mstring.
            REPLACE '&' WITH wa_messtab-msgv4 INTO l_mstring.
          ENDIF.
          CONDENSE l_mstring.
          WRITE: / wa_messtab-msgtyp, l_mstring(250).
        ELSE.
          WRITE: / wa_messtab.
        ENDIF.
        FORMAT COLOR OFF.
      ENDLOOP.
      SKIP.
    ENDFORM.                    " f_bdc_transaction
    FORM F1001_GET_F4.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                PROGRAM_NAME  = SY-REPID
                DYNPRO_NUMBER = SY-DYNNR
                FIELD_NAME    = P_FILE
           CHANGING
                FILE_NAME     = P_FILE
           EXCEPTIONS
                MASK_TOO_LONG = 1
                OTHERS        = 2.
      IF SY-SUBRC <> 0.
      File is not selected
       MESSAGE I000 WITH TEXT-M01.
      ENDIF.
    ENDFORM.                    " F1001_GET_F4

    Sudipta,
    Would request you to post this to ABAP-Forum for Immediate response.
    I had this problem, but the ABAP guy did something to correct this...it was more of screen resoultion difference between the recorded system and uploading system. Please try to use the same system which was used to record and try.
    Regards,
    Prasobh

  • Problem in  Converting String to Date

    Hi All,
    I am having one String
    String date = "2006-01-17 15:19:57.0"
    I want to parse this String into Date object.
    I will really appriciate if somebody helps me out.
    Thanks.

    You're specifying a 'T' and a timezone in your format, but they're not present in the string you're parsing.
    I'm assuming from the way you're printing out the date, that your thinking is along these lines: "sdfInput will parse the input string, no matter what format it's in, and will produce a Date object. That Date object wil have the format specified in sdfInput."
    This is wrong on a couple of fronts:
    1) DateFormat doesn't magically figure out what format it's supposed to use for the String it's parse()ing. The String has to match the DF's format.
    2) Dates don't have formats. Only Strings do. A Date object is just a long. There's no relationship whatsoever between the Date that you get from parse() and the format that was used to produce it. When you print out a Date as you're doing, its toString method is called, which in turn uses a default format for your Locale.
    If you want to turn a date string in one format into a date string in another format, use two different DateFormat objects with two different formats. Date date = df1.parse(inputString);
    String outputString = df2.format(date);

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • I want convert string to date format in Oracle

    Dear All
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'

    >
    Hi Parwez,
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'SELECT TO_DATE('Friday, 02 March 2012 2:44 P.M.', 'DAY, DD MONTH YYYY HH:MI A.M.') from dual;
    As well as what the other poster suggested, look here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
    HTH,
    Paul...

  • Typecasting String to Date using as operator

    Typecasting String to Date using as operator
    I am doing -
    dateId.text as Date;
    but it returns null;
    How should I typecast String to Date in particular format
    like "MM/DD/YYYY"

    "MBhatt" <[email protected]> wrote in
    message
    news:gnlh6f$5gs$[email protected]..
    > Typecasting String to Date using as operator
    >
    > I am doing -
    >
    > dateId.text as Date;
    >
    > but it returns null;
    >
    > How should I typecast String to Date in particular
    format like
    > "MM/DD/YYYY"
    Date has a parse method, and I think DateField has methods
    for this.

  • Converting String to Date

    Hi All,
    I am having a String value which is having date in the format 'Mon Apr 14 16:07:52 IST 2008'
    Now I want to convert this String to Date with format 'mm/dd/yyyy' , to display as 04/14/2008
    Also I want to add 5 days to this date and display the new date 04/19/2008
    I don't know How to convert the string which is having date in 'Mon Apr 14 16:07:52 IST 2008' format to format I need.
    Please help me.

    Hi ,
    I wrote a class that tries to parse a String Date and converts it to object. However, I found a very interesting thing while testing this code. I was trying to paarse "2008:03:04 16:21:05" string by using
    DateFormat.getDateFromString(null,"2008:03:04 16:21:05" )
    It should by pass all try loop accept the one with yyyy:MM:dd HH:mm:ss format. But it went inside the try loop which had MM:dd:yyyy HH:mm:ss format and gave me a wrong date object with year 0171, april 03.
    Could any one help me to understand why it is happening? as a work around I put MM:dd:yyyy HH:mm:ss at the end of the program and it is giving me correct object as it did not have to go that far before matching the format.
    Thanks,
    AL-Amin
    Code:
    import java.text.*;
    import java.util.*;
    public class DateFormat
    public Date getDateFromString(String format, String parseDate)
         Date d;
         if(format!=null) {
    try
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    d = sdf.parse(parseDate);
    catch(Exception e)
    System.out.println(e.toString());
    d = null;
    return d;
         else {
              try
                   format = "yyyy-MM-dd HH mm ss";
         SimpleDateFormat sdf = new SimpleDateFormat(format);
         d = sdf.parse(parseDate);
         catch(Exception e)
         System.out.println(e.toString());
         System.out.println("The Date was not of '"+format+" ' format");
         d = null;
         if(d==null) {
              try
                        format = "yyyy-MM-dd HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "yyyy-MM-dd HH_mm_ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "yyyy-MM-dd HH-mm-ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "yyyy-MM-dd-HH-mm-ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "yyyyMMddHHmmss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "MM-dd-yyyy HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
              if(d==null) {
              try
                        format = "dd-MM-yyyy HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "MM:dd:yyyy HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              try
                        format = "dd:MM:yyyy HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
    if(d==null) {
              try
                        format = "yyyy:MM:dd HH:mm:ss";
              SimpleDateFormat sdf = new SimpleDateFormat(format);
              d = sdf.parse(parseDate);
              catch(Exception e)
              System.out.println(e.toString());
              System.out.println("The Date was not of '"+format+" ' format");
              d = null;
         if(d==null) {
              System.err.println("None of the Date format worked. Please modify the calling method and provide a specific format");
         return d;
    }

  • Problem with converting html to pdf using LiveCycle ES Java API

    I am using this code to convert html to pdf.
    * 1. adobe-generatepdf-client.jar
    * 2. adobe-livecycle-client.jar
    * 3. adobe-usermanager-client.jar
    * 4. adobe-utilities.jar
    * 5. wlclient.jar
    import java.io.File;
    import java.util.Properties;
    import com.adobe.idp.Document;
    import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
    import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
    import com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient;
    import com.adobe.livecycle.generatepdf.client.HtmlToPdfResult;
    public class ConvertHTML {
       public static void main(String[] args)
            try{
            //Set connection properties required to invoke LiveCycle ES                             
            Properties connectionProps = new Properties();
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "t3://localhost:7001");
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,Service ClientFactoryProperties.DSC_EJB_PROTOCOL);       
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "WebLogic");
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
            //Create a ServiceClientFactory instance
            ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
              //Create a GeneratePdfServiceClient object
            GeneratePdfServiceClient pdfGenClient = new GeneratePdfServiceClient(factory);
           //Get an HTML document to convert to a PDF document a
            String inputFileName = "http://www.adobe.com";
            //String inputFileName = "C:\\Documents and Settings\\venkat\\Desktop\\Adobe.htm";
            String securitySettings = "No Security";
            String fileTypeSettings = "Standard";
    System.out.println("one");
            //Convert HTML content to a PDF document
            HtmlToPdfResult result = pdfGenClient.htmlToPDF2(inputFileName, fileTypeSettings, securitySettings, null, null);
    System.out.println("two");         
            //Get the newly created document
            Document createdDocument = result.getCreatedDocument();
            //Save the PDF document as a PDF file
            createdDocument.copyToFile(new File("C:\\test.pdf"));
        catch (Exception e) {
            System.out.println("Error OCCURRED: " + e.getMessage());
            e.printStackTrace();
    I can able to compile this class but while running i am getting error like below.
    Error OCCURRED: Internal error.
    ALC-DSC-000-000: com.adobe.idp.dsc.DSCRuntimeException: Internal error.
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
    :160)
            at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispat
    cher.java:57)
            at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
            at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.htmlToPDF2(GeneratePdfSer
    viceClient.java:666)
            at ConvertHTML.main(ConvertHTML.java:84)
    Caused by: java.rmi.RemoteException: Remote EJBObject lookup failed for 'ejb/Invocation'; nested exc
    eption is:
            org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 203  completed: No
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
    java:101)
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
    :130)
            ... 4 more
    Caused by: org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 203  completed: No
            at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
            at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.writeLock(Unknown Source)
            at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendFragment(Unknown Source)
            at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendMessage(Unknown Source)
            at com.sun.corba.se.impl.encoding.CDROutputObject.finishSendingMessage(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.finishSendingRequest(Unknown Sour
    ce)
            at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete1(Unkno
    wn Source)
            at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknow
    n Source)
            at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(Unknown Source)
            at org.omg.CORBA.portable.ObjectImpl._is_a(Unknown Source)
            at weblogic.corba.j2ee.naming.Utils.narrowContext(Utils.java:126)
            at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
    oryImpl.java:94)
            at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
    oryImpl.java:31)
            at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
            at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
            at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.init(Unknown Source)
            at javax.naming.InitialContext.<init>(Unknown Source)
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initJndiContext(EjbMessageDispat
    cher.java:213)
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.getJndiContext(EjbMessageDispatc
    her.java:226)
            at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
    java:87)
            ... 5 more
    can u plz give me some way to do the convertion.

    Yes Sir.....Thanks for ur suggestion.....
    But i didn't find exact solution..well..yes i found some but not exactly there were not in the way i required...I jus need to convert HTML to PDF using iText API for java.....I already used some classes in that like HTMLParser.....etc..
    So Any thing else...Any one...Sure can help me in this................

  • How to convert a string to date using OLEDB function?

    Is there any function similar to OCIDateFromText()?
    I have to read the date from a text file and store it in the sql database in a date column.
    Please suggest how to do it?
    Thanks in Advance.

    In addition, SQL Server 'likes' YYYYMMDD format to operate with dates.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Facing Problem while Debugging a custom report using LDB

    Hi Gurus,
    I have requirement to modify a custom report program related to FI. This program used Logical database ZDF ( Copied original DDF) for data fetching.
    when i am trying to see the data in debugging mode, its not allowing to check in start-of-selection event. only in the initialization & end-of-selection i could able to debug.
    when i put breakpoint in initialization, it is allowing to see the flow till a Get Event occurs in the code, once a Get event occur the debugger is coming out and displaying the report.
    If anybody faced this kind of problem when debugging a report using LDB, please share how you resolved it. If there are any other ways to debug a program of this kind please help me.
    Thanks,
    Nanda

    Hi Amith,
    I checked that way also, i put break point in database program of the copied LDB, but its not allowing to check the flow in that program also.
    Please suggest any other ways.
    Thanks,
    Nanda

  • Problem in uploading material master data using BDC?

    Hi all,
    I am using  BDC call transaction method to upload material data. Here i am facing a problem that a value in the flat file is going to the wrong screen field . But my recording done properly.
    In recording, after entering the data in the view BASIC DATA1 and trying to enter the text . For this i need to scroll down the scroll bar and after that i am clicking on basic data text and entering the text. Here i am not touching the languge field.
    But the problem is the text to be entered into the basic data text is storing in language and giving error.
    Please help me by specifying the reason and solution for this problem? Whether i did any mistake in recording in scrolling?
    Thanks,
    Vamshi.

    Hi
    Go with BAPI for such huge transactions and screens. Use BAPI: BAPI_MATERIAL_SAVEDATA.
    Regards,
    Vishwa.

  • 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.
    %

  • Convert string to date for Ms Access

    I have some date in a textFile!!!
    I get them via Buffered and FileReader into my java application and put them into a Vector!
    Every date is formatted as Strings and I want to convert them into a date format(YYYYMMDD).
    The date are not used for " System.out.println", but I want to insert them into a Access-database(use a jdbc/odbc bridge).
    The Access database seems only to accept YYYY-MM-DD, the only formatting way is how you choose to "show" the dates (short, long etc) but anyway....(:-)
    I�ve tried following example with format.getTime() and it works. But I want to insert the date from
    my textfiles instead.
    Here some examples from my code with the getTime()method!!!
    String str = String.valueOf(fields.get(3));
    String ar = str.substring(0,4)+"-";
    String m = str.substring(4,6)+"-";
    String d = str.substring(6,8);
    String datum = ar+m+d; //this is my date in a String format!!!
    Calendar calendar = new GregorianCalendar();
    Date date = calendar.getTime();//this objectref. takes the sys.date i want my string date instead(:-)
    DateFormat localFormat = DateFormat.getDateInstance();
    DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd" );//the only format for Access I think!
    for (int j=0; j<(fields.size()-1); j++){//pos. from my vector
    sql = sql + "'" + fields.get(j) + "'" + "," ;     
    sql = sql + "'" + format1.format( date ) "'" ; //the last field i the db
    db myTest = new db();
    myTest.executeDML("insert into tblBooks values "+sql+")");     
    Sorry for my "bumpy" English(:-) And thanks! Eva

    If you tell us what the format if the dates in the file is, we might be able to suggest something :)

  • Converting string to date in mm/dd/yyyy format

    Hi,
    I used simpledateformat to convert date to "MM/dd/yyyy" format.
    Now when i want to insert into db, i want the value as date object instead of string [returned by format method of SimpleDateFormat]
    what should i do?
    Date dt = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    System.out.println("Formatted date is coming as "+sdf.format(dt));
    Date dt1 = sdf.parse(sdf.format(dt);
    System.out.println("parsed date is coming as " +dt1);
    output :
    1 SOP returns 11/07/2007 [current date]
    2 SOP returns Wed Nov 07 00:00:00 GMT+05:30 2007

    If you are using PreparedStatements setDate method, you need a java.sql.Date object, not a Java.util.Date object. You can create an sql.Date object from a util.Date object as follows:
    java.sql.Date sqlDate = new java.sql.Date(dt.getTime());And, if you are not using PreparedStatement and its setDate method, then change now.
    Doing
    Date dt1 = sdf.parse(sdf.format(dt));is meaningless. You format the date to string, then parse the string back to a date? Why? Why not just use the original Date object? And you won't get a sql.Date object that way, either, as the DateFormat classes return a util.Date object.
    Edit: And for more info:
    A Date does not have a format. It is simply a number. The "format" only comes into play when printing the String representation of the Date, and that is not handled by the Date object itself (except when calling toString either explicitly or implicitly).

  • 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.

Maybe you are looking for