Conversion of string 20080315 to 2008-03-15

Hi all,
I have a string in this format 20080315 , but i want it to get displayed as 2008-03-15, how to fit this "-" in between this string using string function ?
Few more examples below
YYYYMMDDhhmmss   should get displyed like this "YYYY-MM-DDThh:mm:ssZ"
Thanks in advance
Asha

use for example CONCATENATE:
DATA: lv_date TYPE d VALUE '20090330',
          lv_date_char TYPE char10.
CONCATENATE lv_date+0(4)
                         lv_date+4(2)
                         lv_date+6(2)
INTO lv_datechar SEPARATED BY '-'.
But when you want to display on screen via WRITE statement you can also use USING EDIT MASK.
See F1 help.

Similar Messages

  • Conversion from string "20041023 " to type 'Date' is not valid.

    Hi ,
       I have a table with one of the column(EmpHiredate) datatype is char(10). It has value like "20141023". I need to display this value as date format(dd/mm/yyyy) in report. 
    Following methods i tried in textbox expression but no luck.
    =Format(Fields!EmpHireDate.Value,"dd/MM/yyyy")
    =Cdate(Fields!EmpHireDate.Value)
    Error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "20041023  " to type 'Date' is not valid.
    Is it possible to convert string to date using SSRS textbox expression ? Can anyone help me with the solution.
    Thanks,
    Kittu

    Hi Jmcmullen,
         Found one more issue on the same. I have one value like "00000000" for the column(EmpHiredate)
    , when i use above expression values(ex:"20141023")
    are displaying in dd/MM/yyyy format in report except value like "00000000" and giving following error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "0000/00/00" to type 'Date' is not valid.
    Even i tried to pass its original value("00000000") as below but no luck.
    =IIF(Fields!EmpHireDate.Value = "00000000","00000000",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Also tried this:
    =IIF(Fields!EmpHireDate.Value = "00000000","2000/10/21",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Please Suggest. 
    Thanks ,
    Kittu

  • Problem with conversion of strings like THISStr - this_str capitalization

    Problem with conversion of strings like. THISStr -> this_str
    Can anybody pass on the reverse code. I have one, but its faulty.
    public static String convertFromPolycaps(String str) {
              Pattern pattern = Pattern.compile("\\p{Upper}+");
              Matcher matcher = pattern.matcher(str);
              StringBuffer result = new StringBuffer();
              // We do manual replacement so we can change case
              boolean notFirst = false;
              int grpP = 0, grpA = 0;
              String last = "";
              String now = "";
              while (matcher.find()) {
                   grpA = matcher.end();
                   if (notFirst) {
                        now = matcher.group().substring(0).toLowerCase();
                        if (grpA - grpP > 1) {
                             matcher.appendReplacement(result, now);
                             result =
                                  new StringBuffer(
                                       result.substring(0, (result.length() - 1))
                                            + "_"
                                            + result.substring(result.length() - 1));
                        } else {
                             matcher.appendReplacement(result, "_" + now);
                   } else {
                        matcher.appendReplacement(result, matcher.group().substring(0).toLowerCase());
                        notFirst = true;
                   grpP = matcher.end();
                   ////index++;
                   last = now;
              matcher.appendTail(result);
              System.err.println(str + " : " + result.toString());
              return result.toString();
         }succesfully converts :
    AccountNmnc : account_nmnc
    CustNameJ : cust_name_j
    Resume : resume
    BeneBrCode : bene_br_code
    ApprovedPerson : approved_person
    but fails for:
    GLCode : glcode
    VISHALErrCode : vishalerr_code
    GHASUNNAcNo : ghasunnac_no

    Can anybody pass on the reverse code. I have one, but
    its faulty.Post it, I'm sure we can fix it...

  • Conversion of string into XML object

    Hi
    I am having some problems with conversion of string (containing XML data) into Flex XML object and binding it later to UI elements to output/maintain this data.
    Binding of XML structure to UI elements works perfectly fine if I will do following:
    1)      Hardcode XML object within Flex file
    2)      Read xml file from repository (xml file inside the Flex project)
    3)      Use HTTP request to retrieve XML data
    Unfortunately none of the above scenarios suits my solution.
    I am developing a prototype application for processing Flex forms inside SAP system. I have decided to make data bindings using XML structure stored in Data Base. When rendering form inside web browser based application I am retrieving corresponding XML schema (empty for new forms and populated for saved forms) and pass it to Flex form as a string type import parameter. Data is being passed correctly (I can display it on TextArea control for instance) but after conversion to XML and binding to DataGrid I am not getting any results.
    I am converting string (containing XML) to XML object in following way:
    Private var xml_obj:XML = new XML(string_xml );
    I am catching any potential errors but conversion is going well. After conversion I am not getting any results after binding it to DataGrid control and I am not able to access any of the nodes using AS code either. At the same time variable xml_obj is not empty (not null).
    Any help would be much appreciated.
    Regards
    Michael

    David
    First of all sorry for not stating it clearly but I am using Flex 3 for this development (at the moment it is the only choice when embedding Flex objects inside SAP applications).
    You must have missed the bit where I am describing how this XML data finds its way inside Flex. I am passing it to Flex as String type parameter during rendering (directly from DB where it is stored).
    Now, following code works perfect (XML is embedded inside Flex project):
                    <mx:XML id="form_data" source="../assets/example_xml_data.xml"/>
                    <mx:Script>
                                    <![CDATA[
                                                    import mx.collections.XMLListCollection;
                                                    import mx.controls.Alert;
                                                    [Bindable]
                                                    public var XML_list:XMLListCollection;
                                                    private function setParameters():void
                                                                   XML_list = new XMLListCollection(form_data.*);             
                                    ]]>
                    </mx:Script>
                    <mx:DataGrid id="myDataGrid" dataProvider="{XML_list}">
                                    <mx:columns>
                                                    <mx:DataGridColumn dataField="COMMON" headerText="Popular name"/>
                                                    <mx:DataGridColumn dataField="BOTANICAL" headerText="Botanical name"/>
                                                    <mx:DataGridColumn dataField="ZONE" headerText="Zone"/>
                                                    <mx:DataGridColumn dataField="LIGHT" headerText="Light"/>                                                                                                                                               
                                                    <mx:DataGridColumn dataField="PRICE" headerText="Price"/>                                               
                                                    <mx:DataGridColumn dataField="AVAILABILITY" headerText="Availability"/>                                    
                                    </mx:columns>               
                    </mx:DataGrid>
    But following code does not work (XML passed to Flex form as String input parameter):
    import sap.FlashIsland;
    import mx.controls.Alert;
    import mx.collections.XMLListCollection;
    [Bindable]
    public var xml_data:String;
    private var form_data:XML;
    [Bindable]
    private var XML_list:XMLListCollection;
    private function initApp():void
                    FlashIsland.register(this);
    private function setParameters():void
                    try
                                    form_data=new XML(xml_data);
                    catch (error:Error)
                                    Alert.show(error.toString());
                      XML_list = new XMLListCollection(form_data.*);           
    XML string does find its way inside Flex form. I can display content of variable xml_data in TextArea and all looks fine. Conversion to XML (variable form_data) goes well (no error)
    Please helpJ
    Regards
    Michael

  • 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

  • "Conversion to String failed"  When attempting to call rs.getString()

    Hello All,
    I'm getting a "Conversion to String failed" exception being thrown from oracle jdbc when I attempting to call the rs.getString(1) method on a column type of DATE.
    During investigations we've found the following:
    1. The query is fine, and is performing a "select * from table".
    2. I see this problem when using 9i database (v 9.2.0.7) with 9i jdbc drivers (v9.2.0.7).
    3. Strangely enough, if I use 10g jdbc drivers with the 9i database this problem goes away, and naturally I don't see this problem at all using a 10g driver working against a 10g database.
    4. Grabbing the DATE value using the getDate() instead of getString() API works just fine in 9i.
    5. The 9i rs.getString() API call will work with some date values in the database and not with others.
    6. The data placed into the DATE column in question could have been placed there using different driver type from the 9i.
    So, the 9i getString() API seems to be a problem.
    At this point, based upon points 5 and 6 above, I'm thinking there is a bug in the oracle 9i jdbc drivers that is unable to convert DATE type data using the getString() API if the data was initially placed into the database using a different driver type. But, this would mean that the format of the data in the database would be different depending upon the means of getting the data there in the first place (which doesn't make much sense).
    Here is the pertinent Stack Trace:
    java.sql.SQLException: Conversion to String failed
    at oracle.sql.Datum.stringValue(Datum.java:173)
    at oracle.jdbc.driver.ScrollableResultSet.getString(ScrollableResultSet.java:684)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1549)
    at com.revenuesolutionsinc.dali.sql.DALResultSet.getString(DALResultSet.java:325)
    Any help on this matter would be greatly appreciated.
    Thanks,
    Doug Newcomb

    Doug,
    Pardon me for stating the obvious, but is there a
    reason why you cannot use method "getDate()" instead
    of method "getString()"?
    For your information, you can report bugs via the
    MetaLink
    Web site.
    Good Luck,
    Avi.Thanks for the reply Avi,
    The main reason is that we've got mountains of code that would need to be refactored. Also, the getString() method worked fine for over a year.
    So we are looking towards finding out why this is happening before making the decision to refactor.
    I will be placing a TAR with Oracle on Monday, but I thought I'd try to find out if anyone else has run into a similar problem.

  • Regional settings impact JavaScript Number conversion to String in applet

    Environment:
    XP, IE6 and IE7, JDK 1.6.0_13,1.6.0_10,1.6.0_7, Apache
    Hi,
    We recently converted our application from the MS JVM to Sun JVM 1.6 and have since had numerous problems with a user's regional setting impacting the application's behaviour.
    The application is using an applet, passing JavaScript Number values to an Applet where the input argument in the Java function is declared as a String.
    We have users with various regional settings, most don't impact the application, but we have found problems when the regional settings are set to "French (France)" or "German (Germany)".
    With "French (France)" JavaScript Number values >=10000000 get truncated to a Java String value of just the first character.e.g. 10000000 is converted to "1", 200000000 is converted to "2".
    With "German (Germany)" a trailing "0" is added to the converted String, and for values >=10000000 we get the String value with an additional 6 "0"s and then 2 additional "0"s as the input Number value is increments by each power of 10.
    A simple example follows.
    Any help understanding why this is happening and any coding solution would be appreciated.
    The default number format for the various regional settings seems to be impacting the implicit conversion to String in LiveConnect.
    We can re-code to convert the Number value to a String in the JavaScript before calling the applet, but this involves significant re-coding of the application.
    We also have a workaround to verify that navigator.userLanguage returns one of the list of supported languages and exit the application if the language is unsupported.
    Thanks
    Rob
    Example output for test:
    OK
    English (United States)
    Regional Settings Number format sample: 123,456,789.00
    lang=en-us,javascript Number=1,Applet Java String value =(1)
    lang=en-us,javascript Number=11,Applet Java String value =(11)
    lang=en-us,javascript Number=111,Applet Java String value =(111)
    lang=en-us,javascript Number=1111,Applet Java String value =(1111)
    lang=en-us,javascript Number=11111,Applet Java String value =(11111)
    lang=en-us,javascript Number=111111,Applet Java String value =(111111)
    lang=en-us,javascript Number=1111111,Applet Java String value =(1111111)
    lang=en-us,javascript Number=11111111,Applet Java String value =(11111111)
    lang=en-us,javascript Number=111111111,Applet Java String value =(111111111)
    lang=en-us,javascript Number=1111111111,Applet Java String value =(1111111111)
    lang=en-us,javascript Number=11111111111,Applet Java String value =(11111111111)
    NOT OK >=10000000
    French (France)
    Regional Settings Number format sample: 123 456 789,00
    lang=fr,javascript Number=1,Applet Java String value =(1)
    lang=fr,javascript Number=11,Applet Java String value =(11)
    lang=fr,javascript Number=111,Applet Java String value =(111)
    lang=fr,javascript Number=1111,Applet Java String value =(1111)
    lang=fr,javascript Number=11111,Applet Java String value =(11111)
    lang=fr,javascript Number=111111,Applet Java String value =(111111)
    lang=fr,javascript Number=1111111,Applet Java String value =(1111111)
    lang=fr,javascript Number=11111111,Applet Java String value =(1)
    lang=fr,javascript Number=111111111,Applet Java String value =(1)
    lang=fr,javascript Number=1111111111,Applet Java String value =(1)
    lang=fr,javascript Number=11111111111,Applet Java String value =(1)
    NOT OK
    German (Germany)
    Regional Settings Number format sample: 123.456.789,00
    lang=de,javascript Number=1,Applet Java String value =(10)
    lang=de,javascript Number=11,Applet Java String value =(110)
    lang=de,javascript Number=111,Applet Java String value =(1110)
    lang=de,javascript Number=1111,Applet Java String value =(11110)
    lang=de,javascript Number=11111,Applet Java String value =(111110)
    lang=de,javascript Number=111111,Applet Java String value =(1111110)
    lang=de,javascript Number=1111111,Applet Java String value =(11111110)
    lang=de,javascript Number=11111111,Applet Java String value =(111111110000000)
    lang=de,javascript Number=111111111,Applet Java String value =(11111111100000000)
    lang=de,javascript Number=1111111111,Applet Java String value =(1111111111000000000)
    lang=de,javascript Number=11111111111,Applet Java String value =(1.1111111111E20)
    Example code:
    Test1.java
    import java.applet.Applet;
    public class Test1 extends Applet {
    public void init() {
    public String stringTest(String str) {
    String out = "Applet Java String value =(" + str + ")";
    return(out);
    index.html
    <html>
    <body>
    <APPLET CODE="Test1.class" NAME="test1" WIDTH="0" HEIGHT="0">
    <PARAM NAME="scriptable" Number="true">
    </APPLET>
    <script type="text/javascript">
    var x;
    document.write("<BR>")
    x = Number("1");
    document.write("lang="+navigator.userLanguage +",javascript Number=" x "," + document.test1.stringTest(x)+"<BR>");
    document.write("<BR>copy/paste the above 2 lines of code, adding an additional '1'<BR>");
    </script>
    </body>
    </html>
    </html>

    I have found a workaround by setting the locale in the applet to a locale that does perform implicit Number to String conversion correctly.
    e.g.
    public void init() {
    try {
    Locale.setDefault(Locale.US);
    } catch (Exception e) {
    System.err.println("Failed to set Locale, Caught Exception: " + e.getMessage());
    and adding this line to the java.policy to prevent "access denied (java.util.PropertyPermission user.language write)" errors.
    permission java.util.PropertyPermission "user.language", "read, write";

  • Conversion from string "" to type 'Double' is not valid

    We're using BPC 7.5 MS and on patch level 111.02
    There's two front-end servers and one back-end.  we have about 100 users but concurrency is likely in the 50 range.
    We've been running extremely well for about 4 years but are now starting to run into problems.
    There are about 5-6 applications but none greater than 10 million records.  We optimize regularly.
    However over the past two months admin processes seem to take a lot longer.  Optimization now times out after about 1.25 hours and none used to take greater than 15 minutes.
    Today after processing dimensions we checked the application status and we were not able to check if it was available or not.  We got a pop up box saying
    conversion from string "" to type 'Double' is not valid
    I've processed dimensions and applications since and still this error persists.
    We're attempting a reboot to see if that helps but I've never seen this before and in combination with the slower admin processing I'm wondering if there's something drastic going to happen.
    Michael

    Hi Michael,
    for the poor performances you have to check the guides about performance on bpc if you have scheduled regurarly optimize during day and night (just verify that never factwb reach 50.000 and fac2 500.000 records) maybe you need to change some parameter on the server as MaxThreads.
    For the conversion string error on admin console see please this note 1803092 - Set application set status error
    Regards
         Roberto

  • XSU error oracle.xml.sql.OracleXMLSQLException: Conversion to String failed

    Appication Server: 10g, Database: Oracle 9i and Oracle 10g
    I have a table 'sw_icd2' in the database that has one column of XMLType.
    The code below, attempts to query this table as 'select * from sw_icd2' and display the result. I was able to execute this query in sqlplus.
    But when I run a program using XSU in JDeveloper:
    OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from sw_icd2");
    XMLDocument domDoc = (XMLDocument)qry.getXMLDOM();
    domDoc.print(System.out);
    StringWriter s = new StringWriter(10000);
    domDoc.print(new PrintWriter(s));
    System.out.println(s.toString());
    qry.close();
    I get the following Error:
    "oracle.xml.sql.OracleXMLSQLException: Conversion to String failed"
    Any ideas on how I can resolve this issue? Your help would be appreciated.
    Thanks!

    Okay, it looks like the problem has something to do with the TIMESTAMP data type in tables.
    oracle.xml.sql.query.OracleXMLQuery can't seem to handle tables with the TIMESTAMP data type.
    this code ran fine on my machine :
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    import java.lang.*;
    import java.sql.*;
    public class testXMLSQL {
         public static void main(String[] args) {
    try {
    // Create the connection
    System.out.println("before getConnection ");
    Connection conn = getConnection("scott","tiger");
    System.out.println("after getConnection ");
    // Create the query class
    OracleXMLQuery qry = new OracleXMLQuery(conn, "SELECT * FROM EMP");
    System.out.println("after OracleXMLQuery object created ");
    // Get the XML string
    String str = qry.getXMLString();
    // Print the XML output
    System.out.println("The XML output is:\n"+str);
    // Always close the query to get rid of any resources..
    qry.close();
    } catch(SQLException e) {
    System.out.println(e.toString());
    // Get the connection given the user name and password.!
    private static Connection getConnection(String username,
    String password)
    throws SQLException
    // register the JDBC driver..
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    // Create the connection using the OCI8 driver
    Connection conn =
    DriverManager.getConnection(
    "jdbc:oracle:thin:@<server_name>:1521:<sid>",
    username,password);
    return conn;
    Then I created another table :
    create table emp_test as select * from emp;
    added a timestamp to it :
    alter table emp_test add (time timestamp(6));
    and filled it with timestamp information :
    update emp_test set time = timestamp'2005-09-22 09:26:50.124';
    ran the same code but changed the SQL to :
    "SELECT * FROM EMP_TEST"
    and got the error message :
    The XML output is:
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Conversion to String failed</ERROR>
    looks like bug in OracleXMLQuery object??

  • Deprecated conversion from string constant to 'char*'

    Hi all
    I am working with strings and i cant figure out why the following
    warning appears at time of build.
    warning: deprecated conversion from string constant to 'char*'
    It appears for the line
    char *myName = "Apple.txt";
    Is there anyone who can help me?
    Help is welcome.
    Thanks in advance.

    Any reason why you aren't using NSString in place of char?
    char *myName = "Apple.txt";
    NSString *myName = @"Apple.txt";

  • Regarding conversion of String to Date

    Hi
    Ravi here and I am getting the following exception when i am working with String to date conversion.As i am working in LAN this code is working for all others .This problem is with my system only.This is not supporting with yyyy-MM-dd format.One more thing in my system only we installed VisualStudio.Is that a problem for this exception.I am using Myeclipse
    Plzzzzzzzzzzz help me I got strucked .
    Thanks in advance
    Code:
    public void testSaveDates() throws HibernateException, ParseException{
    try{
    Date date=new Date();
    String str1 ="2006-05-06";
    Date dateFormatter = new SimpleDateFormat("yyyy'-'MM'-'dd").parse(str1);;
    System.out.println(dateFormatter);
    catch(Exception e){
    e.printStackTrace();
    Exception:
    java.text.ParseException: Unparseable date: "2006-05-06"
         at java.text.DateFormat.parse(DateFormat.java:335)
         at chaitanya.MyTest.testSaveDates(MyTest.java:282)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

    Date date=new Date();You don't need this line.
    Date dateFormatter = new
    er = new
    SimpleDateFormat("yyyy'-'MM'-'dd").parse(str1);;As already told, you don't need the single quotes. And you don't need two semi-colons - that's unnecessary.
    I just wrote a sample code to test that out. Check it and see for yourself.
    import java.text.SimpleDateFormat;
    public class Test {
         public static void main(String[] args) throws Exception {
              System.out.println(new SimpleDateFormat("yyyy-MM-dd").parse("2005-04-18"));
              System.out.println(new SimpleDateFormat("'yyyy'-'MM'-'dd'").parse("2005-04-18"));
    }Output:
    Mon Apr 18 00:00:00 EDT 2005
    Exception in thread "main" java.text.ParseException: Unparseable date: "2005-04-18"
            at java.text.DateFormat.parse(DateFormat.java:335)
            at Test.main(Test.java:6)I wonder why it is not feasible to write a quick sample code.

  • Conversion of String to byte[ ]

    Hi everybody
    I have a Byte[] value in one of our client database it seems like this -- 00033DB7FB87EC4EB371BCC9D3BF13EC
    when they import into CSV it became String
    I need to Dump into my database what ever you see in that Byte[].the value is already a conversion only so i need to dump as it is.
    now the real problem is how to convert the same String as Bytes
    if i use String.getBytes() it exceeding the Field Length
    my filed length in the database is Binary (16)
    Plz do the needful
    Thanks for ur Help in advance

    So System.out.println(theString) results in "00033DB7FB87EC4EB371BCC9D3BF13EC"?
    Then .getBytes() is not what you need. It will get the bytes representing this unicode string in a specific encoding (such as ISO-8859-1, UTF-8 or the like).
    You need to parse to digits each as hexadecimal numbers (using Integer.parseInt() for example, don't forget to specify the radix 16) and convert that to a byte[] array (the length of the byte array should be half the size of the String).
    Warning: because Java knows only signed ints, you'll have to jump through some hoops to get the correct value. Assuming String a contains 2 hexadecimal digits, you get the byte value like this:
    byte b = (byte) (Integer.parseInt(a,16) & 0xFF);

  • Query on conversion between String to Enum type

    Hi All,
    I would like to get advice on how to convert between char and Enum type. Below is an example of generating unique random alphabet letters before converting them back to their corresponding letters that belonged to enum type called definition.Alphabet, which is part of a global project used by other applications:
    package definition;
    public enum Alphabet
    A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S,
    T, U, V, W, X, Y, Z
    public StringBuffer uniqueRandomAlphabet()
    String currentAlphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    StringBuffer randomAlphabetSB = new StringBuffer();
    for (int numberOfAlphabet=26; numberOfAlphabet>0; numberOfAlphabet--)
    int character=(int)(Math.random()* numberOfAlphabet);
    String characterPicked = currentAlphabet.substring(character, character+1);
    // System.out.println(characterPicked);
    randomAlphabetSB.append(characterPicked);
    StringBuffer remainingAlphabet = new StringBuffer( currentAlphabet.length() );
    remainingAlphabet.setLength( currentAlphabet.length() );
    int current = 0;
    for (int currentAlphabetIndex = 0; currentAlphabetIndex < currentAlphabet.length(); currentAlphabetIndex++)
    char cur = currentAlphabet.charAt(currentAlphabetIndex);
    if (cur != characterPicked.charAt(0))
    remainingAlphabet.setCharAt( current++, cur );
    currentAlphabet = remainingAlphabet.toString();
    return randomAlphabetSB;
    // System.out.println(randomAlphabetSB);
    I got the following compilation error when trying to pass (Alphabet) StringBuffer[0] to a method that expects Alphabet.A type:
    inconvertible types
    required: definition.Alphabet
    found: char
    Any ideas on how to get around this. An alternative solution is to have a huge switch statement to assemble Alphabet type into an ArrayList<Alphabet>() but wondering whether there is a more shorter direct conversion path.
    I am using JDK1.6.0_17, Netbeans 6.7 on Windows XP.
    Thanks a lot,
    Jack

    I would like to get advice on how to convert between char and Enum type. Below is an example of generating unique random alphabet lettersIf I understand well, you may be interested in method shuffle(...) in class java.util.Collections, which randomly reorders a list.
    before converting them back to their corresponding letters that belonged to enum type called definition.AlphabetIf I understand well, you may be interested in the built-in method Alphabet.valueOf(...) which will return the appropriate instance by name (you'll probably have no problem to build a valid String name from a lowercase char).

  • SQL 2000 ODBC CONNECTION STRING FOR SQL 2008

    i have vb 6 application. Database is SQL server 2000.
    my connection string is (using odbc driver),
            .ConnectionString = "Driver={SQL Server};SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
    Now i have tried this application with SQL server express 2008 R2
    Can i still keep the old connection string? will there be any problem in future?
    (if i have to change then have to change at so many places.....)
    I can run application without any problem for now (not changed connection string to new one)
    otherwise i have to use ODBC or OLEDB which are,
            .ConnectionString = "Driver={SQL Server Native Client 10.0};SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
    or
            .ConnectionString = "Provider=SQLNCLI10;SERVER=" & mServer & ";DATABASE=mydb;UID=" & mLogin.Username & ";pwd=" & mLogin.Password & ";"
    if i have to change to new connection string Which one is better to use odbc or oledb.
    h2007

    personally I favor ODBC as it is easy to use sometime. Additionally you can check the link below:
    http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/19e0c306-0be4-46b5-b207-0937931d63a7 
    cheers!!!
    Vatsa
    www.objectiveprogramming.com

  • Issue in Conversion of String to XML (xsd) elements.

    Hi All,
    Please help in resolving the below issue.Please help me ASAP
    I am getting a strng value from Db adapter String= Mike,3453,USA
    I need to convert the data into xml by using below xsd.
    <?xml version="1.0" encoding='UTF-8' ?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.uss.com/htr/IHCM204/MainRec"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    xmlns:tns="http://www.uss.com/htr/IHCM204/MainRec"
    attributeFormDefault="unqualified" nxsd:version="NXSD"
    nxsd:stream="chars" nxsd:encoding="US-ASCII">
    <element name="MainOutput">
    <complexType>
    <sequence>
    <element name="Target" maxOccurs="unbounded">
    <complexType>
    <sequence>
    <element name="name" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
    <element name="sal" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
    <element name="add" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    </element>
    </schema>
    Regards,
    Ana

    Say, for Example
    If you are getting response from db adapter as abc,def,ghi then use an transform activity to split the string.
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <xsl:template match="/">
    <ns:StringParsing>
    <ns:Name>
    <xsl:value-of select='substring(/ns:simpleelement/ns:dbString,1.0, oraext:last-index-within-string(/ns:simpleelement/ns:dbString,",") + 0.0)'/>
    </ns:Name>
    <ns:Address>
    <xsl:value-of select='substring(/ns:simpleelement/ns:dbString,oraext:last-index-within-string(/ns:simpleelement/ns:dbString,",") + 2.0)'/>
    </ns:Address>
    </ns:StringParsing>
    </xsl:template>
    </xsl:stylesheet>
    Let me know if it helps you.
    Edited by: BK574 on May 14, 2013 11:31 AM
    Edited by: BK574 on May 14, 2013 11:55 AM
    Edited by: BK574 on May 14, 2013 12:48 PM

Maybe you are looking for

  • Some reports do not work after upgraded to Crystal Report 2008

    Hi All, After upgraed from Crystal Report XI to Crystal Report 2008, some reports work fine. others not. All of the not-working reports have the same problem: Database connection failed. And I can even not be able to create a brand new report. The pr

  • Does anyone have any info re 3.5mm jack microphones on the Mac Pro?

    Please, don't refer me to the manufacturer...am working on that, in the meantime i'm looking for anyone that might have OTHER information or suggestions regarding this issue... Bought a GE PC Microphone, a very simple on with a 3.5MM jack. The packag

  • How to install Windows 7 Enterprise using Bootcamp ?

    Hi, I'd like to install Windows 7 entreprise edition on a macbook pro 15" Early 2011 using Lions latest version. I have an orginal CD and also an ISO file. I tried this: - insert the original DVD, start bootcamp, downloaded the drivers and restarted

  • FB02 - Payment Block

    Hello, We have a security requirement to control the payment block field in transaction FB02. Does anyone know if any authorization objects exist for this field?

  • Time machine verify backups sticks at 69%

    Mac os mountain lion 0s 10.8.2 No longer a disk image on the desktop but backup seems to be working.  Verification sticks on 69% Any help appreciated