Convert from String data type to Character data type

Hi...,
I'm a beginner. I try to make a program. But I don't know how to convert from string to data type. I try to make a calculator with GUI window. And when somebody put "+" to one of the window, I just want to convert it to Character instead of String.
Sorry of my bad english..
Please help me....
Thanks

String s = "a+b";
char theplus = s.charAt(1);

Similar Messages

  • Convert XML string into an abap format date and time

    Hi,
    Does anyone know of a method or a function module in ABAP which converts XML string into an abap format date and time.
    Here is a part of the xml that I want to convert.
    <ns2:EventDateTime>2009-07-02T10:13:45+10:00</ns2:EventDateTime>
    <ns2:EventMessageTransmissionDateTime>2009-07-02T10:13:45.987+10:00</ns2:EventMessageTransmissionDateTime>
    Currently EventDateTime and EventMessageTransmissionDateTime are type XSDDATETIME_Z and these are converted to proper dates and times. We will be changing these fields to a STRING instead of XSDDATETIME_Z. The reason for this is to make the field more versatile. The customer would be receiving dates with Zulu (2009-09-23T12:00:00Z), with offsets (2009-09-23T12:00:00+10:00/-10:00) and just local timestamp (2009-09-23T12:00:00). With this, we need to make the date fields as string
    to be able to accept the various date formats (esp. the local timestamp).
    I am looking for a standard function module or method that will convert the xml string to a proper date and time abap format.
    Would appreciate anyone's help!
    Thanks.
    Edited by: eunice ocson on Jul 13, 2009 1:49 AM
    Edited by: eunice ocson on Jul 13, 2009 1:50 AM
    Edited by: eunice ocson on Jul 13, 2009 1:51 AM
    Edited by: eunice ocson on Jul 13, 2009 1:51 AM

    Hi Eunice
    Use the FM 'SMUM_XML_PARSE'
    for more info
    [Convert XML string to ABAP|XML String to ABAP or GUI]
    hope it helps you.
    Thanks!!

  • 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

  • Convert from String to boolean ??

    hi everyone..
    is there any way to convert from String (as a class) to boolean (as a primitive type) ?
    thunx

    I used : Boolean.valueOf(s).booleanValue(); ,I got the same error.What same error? Surely not this one:
    cannot resolve simple in parseBoolean method??
    equals is OK, but I think it is not convert method,
    the prev. solutions by equals don't convert the value of s (String).Yes it does, for any reasonable definition of "converts". In fact, that is essentially how parseBoolean() is implemented. From the JDK 5.0 source code, class java.lang.Boolean:
         return ((name != null) && name.equalsIgnoreCase("true"));

  • Convert from String to HashMap

    Hi
    Can any body pls tell us how to convert from String to HashMap
    I have one string str="Col1=200, Col2=225";
    So how can i convert that string varibale into HashMap?

    Hi
    Can any body pls tell us how to convert from String
    to HashMap
    I have one string str="Col1=200, Col2=225";
    So how can i convert that string varibale into
    HashMap?
    Map map = new HashMap();
    String[] parts = str.split(", ");
    for (int i = 0; i < parts.length; ++i) {
        String[] entry = parts.split("=");
    map.put(entry[0], entry[1]);

  • Convert from String to Int

    Hi,
    I have a question.
    How do I convert from String to Integer?
    Here is my code:
    try{
    String s="000111010101001101101010";
    int q=Integer.parseInt(s);
    answerStr = String.valueOf(q);
    catch (NumberFormatException e)
    answerStr="Error";
    but, everytime when i run the code, i always get the ERROR.
    is the value that i got, cannot be converted to int?
    i've done the same thing in c, and its working fine.
    thanks..

    6kyAngel wrote:
    actually it convert the string value into decimal value.In fact what it does is convert the (binary) string into an integer value. It's the String representation of integer quantities that have a base (two, ten, hex etc): the quantities themselves don't have a base.
    To take an integer quantity (in the form of an int) and convert it to a binary String, use the handy toString() method in the Integer class - like your other conversion, use the one that takes a radix argument.

  • Convert from String to Long

    Hello Frineds I want to convert from String to Long.
    My String is like str="600 700 250 300" and I want to convert it to long and
    get the total value in to the long variable.like the total of str in long varible should be 1850.
    Thank You
    Nilesh Vasani

    Maybe this would work?
    StringTokenizer st = new StringTokenizer(yourString, " ");
    long l = 0;
    while(st.hasMoreTokens()) {
        l += Long.parseLong(st.nextToken()).longValue();
    }

  • Convert from String to float

    How do I convert from String to float?

    Hi,
    you can use a Double for example - assuming value is that string to parse
    float f;
    try { Double d = new Double(value); f = d.floatValue(); }
    catch (NumberFormatException e) { f = 0.0; } // error - string value could not be parsed
    // here use your float fHope, that helps
    greetings Marsian
    P.S.: the Double class is usefull for that, because you also can get intValue(), doubleValue() or longValue() out of it for example. The StreamTokenizer for example parses numbers also only to double.

  • Date Formatting, Converting from String to Timestamp

    I am trying to convert a string date to timestamp.
    I have tried a couple of different ways to arrive at the end result.
    I am basically trying to convert a date in the "dd-MM-yyyy" format to a timestamp.
    If I use the following code, I get a date like this "18-May-2004 12:00:00 AM".
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy);
    Date dContractDate = sdf.parse("18-05-2004");
    long dateInMilli = dContractDate.getTime();
    bHelp.bcontractdate = new Timestamp(dateInMilli);
    How can I make this code display the current time not midnight or some defaulted value?
    Thanks.

    I think a clever person would reuse their Date.classObject and call Date.setTime() as opposed to always
    rolling out a new Date()
    Not really a question of cleverness. Your code wins
    nothing. Objects are not magically created and garbage collected in the ether.
    The cost of creating a Date is nothing
    compared to the cost of a format() call. True, but not valid a valid statement pertaining to the issue which is
    "does always rolling dates suffer a performance hit?"
    Plus you lost clarity Maybe you loose track of your code if you don't make new Objects all the time,
    but I have never suffered from this.
    Why do you think Sun provided the setDate() method?
    and thread-safety.I have only had Thread issues when I didn't program them properly.
    Luckilly I always program the correctly ;) (Touch wood)
    The facts as I seem are thus:
    Rolling new dates on a 1.83 GHZ PC incurrs on average
    a 19% penalty. Here is the proof.
    Save this program and save it as DateTest.java
    If you don't want to waste the time here are the results of running it
    through the default 10 iterations.
    Running 10 iterations.
    Reuse of dates is 27% more efficient
    Reuse of dates is 17% more efficient
    Reuse of dates is 18% more efficient
    Reuse of dates is 20% more efficient
    Reuse of dates is 20% more efficient
    Reuse of dates is 17% more efficient
    Reuse of dates is 17% more efficient
    Reuse of dates is 20% more efficient
    Reuse of dates is 20% more efficient
    Reuse of dates is 18% more efficient
    Gaining "nothing " actually = 19% on average
    Low percent diff = 17 High percent diff = 27
    Run it 100 times and it should still be around 19%
    With the hi time being about 47% (Probably the result of garbage collecting)
    //////////////////////////////////// <PROOF> ///////////////////////////////////////
    import java.util.Date;
    public class DateTest
    DateTest()
    public int run()
    int percent = 0;
    int loopCount = 0;
    Date date = null;
    int z=0;
    long start1=0,end1=0,start2=0,end2=0,now=0;
    int time1 = 0,time2 = 0;
       now = System.currentTimeMillis();
       date = new Date(now);
       loopCount = 10000000;
       start1    = System.currentTimeMillis();
       for(z=0;z<loopCount;z++)
          now = System.currentTimeMillis();
          date.setTime(now);
       end1 = System.currentTimeMillis();
       start2    = System.currentTimeMillis();
       for(z=0;z<loopCount;z++)
          now   = System.currentTimeMillis();
          date  = new Date(now); // use 'now' so test loops are =.
       end2 = System.currentTimeMillis();
       time1 = (int)(end1 - start1);
       time2 = (int)(end2 - start2);
       percent = ((time2-time1)*100/time2);
       System.out.println("Reuse of dates is "+percent+"% more efficient");
       return percent;
    public static void main(String args[])
    int z=0;
    int lowP=100,hiP = 0;  // lowpercent/highpercent
    DateTest d = new DateTest();
    int loopCount = 0;
    long totals   = 0;
    int average   = 0;
    int values[];
    int retVal = 0;
       try // Yea olde Lazy person's command line handler :)
          loopCount = Integer.parseInt(args[0]);
       catch(Exception any)
          loopCount = 10;
       if(loopCount == 0)
          loopCount = 10;
       values = new int[loopCount];
       System.out.println("Running "+loopCount+" iterations.");
       for(z=0;z<loopCount;z++)  //
          retVal = d.run();
          if(lowP > retVal)
             lowP = retVal;
          if(hiP < retVal)
             hiP = retVal;
          values[z] = retVal;
       for(z=0;z<loopCount;z++)
          totals += (long)values[z];
       average = (int)(totals/loopCount);
       System.out.println(" Gaining \"nothing \" actually = "+average+"% on average");
       System.out.println("Low percent diff = "+lowP+" High percent diff = "+hiP);
    }////////////////////////////////// </PROOF> /////////////////////////////////////////
    Your "nothing" is in fact on average about a 19% performance hit. per call.
    These inefficiencies build up and java is infested with the,
    Was it not so the java would run much more efficiently than it now does.
    Ask yourself; why did Sun supply the setDate() method???
    (T)

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

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

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

  • Convert from string to datetime

    I'm getting a date from a textbox in form and i want to insert it into the database....The format of the date i let user key into the textbox is 2003/03/28...But the field of the date in the database is in this format 2003-02-25 00:00:00.000 so when i try to insert this value into the field i encountered problem....can anyone pls help to solve this problem
    Thank You very much

    if you use a date type in your database,
    you will have to use a java Date type
    try something like this :
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy/MM/dd");
    String s = "2003/02/15";
    java.util.Date dateU = sdf.parse(s);
    java.sql.Date dateS = new java.sql.Date(dateU.getTime());
    and to insert :
    java.sql.PreparedStatement statement;
    statement.setDate(pos,dateS );

  • Is it possible to convert from string to variant?

    Hi!
    I would like to convert a text string to variant. I'm doing this because I would like to merge a couple of signals and then save all the signals in a lvm-file. Could someone please explain how to convert from text to variant, is it possible?
    Thanks in advance!
    Regards,
    Mattias
    Attachments:
    Merge signals.JPG ‏27 KB

    What you are attempting to do is possible, but might not give you the results you expect.  All you need to do is convert your string to an array of U8s using the String to Byte Array conversion primitive.  In the file, you will get a single character per line of the file expressed as the ASCII code.  When you read it, convert to U8s, then use Byte Array to String to get your string back.
    You may also want to read up on LVM files.  There are several places to put strings that work a little better than this.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Take the average of the measured values wich cannot be converted from string to number..

    Hello,
    I have a Keithley 182 Digital Nanometer (K182). I am usins it to measure voltage at high temperature. I want K182 to measure 3 times and then take the avarage of collected data.
    1. First problem is, as you can see from picture, string to number conversion. I tried many ways but I couldn't do it. Values as you see 0,00, and once was
    3,98E-3
    0,00
    392,0
    originan values were
    3,98E-3
    3,95E-3
    3,93E-3
    in table, values generally like this.
    2. I need to take avarege. So i need toindez data, then take avarage. So, I have also problem here...
    Could you please help on thic topic. Thanks in advance.
    Attachments:
    string-number.png ‏19 KB
    string-number-panel.png ‏30 KB

    thank you, I will try this solution. Also I want to do one more thing. So, I am collecting data and putting them in to table let say data are like this
    Temp1     Temp2   Volt
    123,3       234,5      ...
    234,4       567,7
    345,6       789,9
    456,7       678,8
    I want to put data with increment like this given below:
    No  Temp1     Temp2   Volt
    1    123,3       234,5      ...
    2    234,4       567,7    
    3    345,6       789,9
    4    456,7       678,8
    there are no exact number of data. the number of data can change from measurement to measurement (1000, 2000, 500 more or less). How can I program this increment in my system.
    My system is include LakeShore 336 temperature conroller and Keithley 182 Nanovoltmeter. I will set the temperature specified value from room temperature wtih specific ramp rate. Meanwhile I will measure the voltage from sample via K182. So, I can measure both temp, and voltage via taking help from u.

  • Convert from String to Date for storing in SQL Server 2000

    Hi,
    I've accepted some values from a user using a form in HTML.Now using Servlets I transfer the value to my java code .
    I want to know how can I convert a DATE accepted from the user thats presently in "String" format to the "datetime" format for SQL Server2000.
    Please guide me with some steps and I shall be grateful.
    Thanks

    The java.text.SImpleDateFormat class is most probably of use.
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    String enteredDate = "25/12/2006";
    java.util.Date utilDate = sdf.parse(enteredDate);
    java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());You can then use the java.sql.Date with the "setDate()" method of a prepared statement. This method would be database independant, as you are setting an actual date, not depending on a specific format on the database end.

  • Convert from String to Date

    Hello,
    I have the following string: "Thu Apr 22 00:00:00 IDT 2004"
    and I need to convert it to Date object.
    I tried to use Date.parse() and Date.valueOf(),
    but then I get the IllegalArgumentException.
    How can I do this?
    Thanks.

    split ur string. get year,month,day in int
    time in long
    now it will work for u
         Date d = new Date(int year,int mon,int date);//Deprecated
         d.setTime(long time); //Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
         System.out.println(d);
    Ignore that answer, please and DynaFest read the API!

Maybe you are looking for

  • Can we create Return Sales Order with Ref to Delivery

    Dear Friends, Can we create a Return sales order (RE) with reference to Delivery (LF)? If yes,how? If not,why? Regards, Shrikant

  • Issue with SaveAs PDF using XSLFOP

    Hi, We have been using SaveAs method to generate PDF files using XSLFOP technique successfully, however, recently we ran into an issue where a very large report (about 100+ pages) generated a PDF file that could not be opened. We get the following er

  • Finding last update of record

    Hello, Our DBA wants to know which records have been updated since the last backup so that he can back up only those records that have been added/changed on the next backup. He is putting a column called Timestamp in each table he wants to do this fo

  • Team Viewer Issue

    How do I set up the Team Viewer in MSS? I have set up the ODAP, but not sure how to link it to the Team Viewer iView in MSS with the relevant view (MSS_TMV_EE_DIR)? Thanks

  • Error Code U44M1P210 Adobe Application Manager?

    After installing the trial for Adobe Premiere Elements 11, I get error messages whenever I run updates on my existing (installed) CS5 software. The main error code is:  Adobe Application Manager - There was an error installing this update. Please qui