Need help to convert this format of string in a int value?

public static int isNumber( String number, int defaultValue ) {
          int result;
          try {
               result = Integer.parseInt(number);
          } catch( Exception e ) {
               result = defaultValue;
          return result;
     }Hi, I have the above method that converts a string Number into a int value. It works fine if the string is a normal number 234 (without spaces) but I have a string in the following format:
*(space)�23,000(space).*
That is I have a "space" then a "Pound" sign then two numbers then a comma followed by three numbers and then a space again.
Is there any way I can convert this format into a simple int value?
Thanks for any guidance.
Zub

Hi, I tried the following code but it don't seem to work
     public static int isNumberTrimSpaces( String number, int defaultValue ) {
          number.trim();
          String parsed = "";
          for (int i = 0 ; i < number.length() && number.charAt(i) != ',' ; i++)
         if (Character.isDigit(number.charAt(i))) {
         parsed += number.charAt(i);}
          int result;
          try {
               result = Integer.parseInt(number);
          } catch( Exception e ) {
               result = defaultValue;
          return result;
     }Any Ideas? Also will the loop get rid of the pound sign?

Similar Messages

  • Need help in converting date format

    Hi,
    Need help in converting date format from 'DD-MON-YYYY' to 'YYYY-MM-DD' in an .rtf template as I believe xml publisher supports the date format as 'YYYY-MM-DD' only.
    Thanks,
    Raj.

    I got the same problem, anyone know how to solve this problem? I allready found some date functions on http://blogs.oracle.com/xmlpublisher/2008/09/date_functions.html . I also tried <?xdoxslt:month_name(xdoxslt:get_month(xdofx:substr(NEED_BY_DATE, 4,3)), $_XDOLOCALE), 0, 'nl-NL')?>, but then it returns a namespace error (Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'xdofx' used but not declared.). Anyone know how to fix this?
    Edited by: user11165753 on 7-dec-2009 23:50

  • Need help with converting date format to decimal in SSRS expression.

    Hi all,
    I have a decimal data type column with a record in the following format 20150219 --> yyyyMMdd. And I am trying to convert the return value from SSRS date/time parameter to a decimal value.
    The TMDTOP column is the decimal data type with date records in yyyyMMdd format.
    My return parameter is the following:
    =IIf(IsNothing(Parameters!SystemDate.Value),Fields!TMDTSY.Value,CDec(Format(Parameters!SystemDate.Value,"yyyyMMdd"))) 
    When I try to run the report I get the following error:
    Failed to evaluate the FilterValue of the DataSet ‘DataSet1’. (rsFilterEvaluationError)
    I appreciate if anyone can help me on solving this problem.
    Thanks in advance.

    why casting date to decimal here? Can you explain?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need help in converting numbers to Italian text

    Need help in converting numbers to text in Italian language. I want to knw is there any method other than SE63 to translate these text in one shot. I have tried with LSMW also (as the sheet is in XLS format ).Plz reply if anyone is aware of this ..

    hi,
    chk this code.
    CALL FUNCTION 'SPELL_AMOUNT'
    EXPORTING
    amount = amount
    currency = 'EUR'
    filler = ' '
    language = 'E'  => give the language as italian
    IMPORTING
    in_words = amountrs.
    rgds
    anver
    pls mark all hlpful answers

  • Need help to convert SQL MSSQL statement to work with PL in ORACLE

    Hi All,
    I have the trigger below and it worked on MSSQL server for windown and
    I really need your help to convert this trigger to work on PL/ORACLE:
    create trigger deleteLD
         on tablea for delete
    as
    set nocount on
    begin
         declare @tablename varchar(100)
         declare @dropSql varchar(50)
         select @tablename= dataset from deleted
         set @tablename = 'LD_' + @tablename
         set @tablename = @tablename + 'UTMSTATS'
         if exists (select * from sysobjects where name = @tablename)
         begin
              set @tablename = 'drop table ' + @tablename
              EXEC (@tablename)
         end
    end
    GO
    Your help is greatly appreciated.
    Thanks,
    JP

    not sure if this is something that you want:
    Create Or Replace Trigger deleteLD
      Before Delete on tablea
    Declare
      vCtr          number := 0;
    Begin
    select count(*)
       into vCtr
       from all_tables
      where table_name = :new.tablename;
    if vCtr > 0 then
       dbms_utility.exec_ddl_statement('drop table '||:new.table_name);
    end if;
    End;note: not tested

  • I need help instantly on this program please

    import java.util.*;
    public class D3
              private static int[] z = new int[100000];
    private static int first=z[0];
              private static int last=z[n-1];
              private static int n=100000;
    public static void main(String args[])
    Scanner input=new Scanner(System.in);
    for(int i=0;i<z.length;i++)
              z=2*i;
    int seqSearch(z;50000;n); //method call 4 key where key=mid
              int binSearch(z;first;last;50000);
              int seqSearch(z;35467;n); //method call 4 key where key in the left half
              int binSearch(z;first;last;35467);
              int seqSearch(z;89703;n); //method call 4 key where key in the right half
              int binSearch(z;first;last;89703);
              public int seqSearch(int z[];int key;int n)
         long start = System.currentTimeMillis();
    int count=0;
    int ans=-1;
    for(int i=0;i<n;i++)
    if z[i]=key
    count++
    {ans=i
    break;}
    return ans;
    long elapsed = System.currentTimeMillis() - start;
    System.out.print("Execution Time:" + elapsed);
    System.out.print("# of Basic Operations:" + count);
         public int binSearch(int z[];int first;int last;int key)
         long start = System.currentTimeMillis();
         int count=0;
         if(last<first){
         count++;
         index=-1;
         else
         count++;
         int mid=(first+last)/2
         if(ket=z[mid]{
         index=mid;
         else
         if(key<z[mid]){
         index = binSearch(z[];first;mid-1;key);
         else
         index=binSearch(z[];mid+1;last;key);
         return index;
         long elapsed = System.currentTimeMillis() - start;
         System.out.print("Execution Time:" + elapsed);
         System.out.print("# of Basic Operations:" + count);
    // if anyone could tell me whats wrong with my code i'd be greatful...the program is supposed to perform binary and sequential search on a sorted array of 100000 numbers.once on an item in the middle of the array once on the right side of it and once on the left side...i also need to count the number of basic operations for the same number in both sequential and binary to see whats better.and i need to check the time...plz i need help now,,,

    "Guide to a first-time poster"
    you need to add exclamation marks to signify how urgent it is
    e.g.
    i need help instantly on this program please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    capital letters is better
    I NEED HELP INSTANTLY ON THIS PROGRAM PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    starting the italics on line 1, better again
    import java.util.*;
    public class D3
    private static int[] z = new int[100000];
    private static int first=z[0];
    private static int last=z[n-1];
    private static int n=100000;
    public static void main(String args[])
    Scanner input=new Scanner(System.in);
    for(int i=0;i<z.length;i++)
    z=2*i;
    int seqSearch(z;50000;n); //method call 4 key where key=mid
    int binSearch(z;first;last;50000);
    int seqSearch(z;35467;n); //method call 4 key where key in the left half
    int binSearch(z;first;last;35467);
    int seqSearch(z;89703;n); //method call 4 key where key in the right half
    int binSearch(z;first;last;89703);
    public int seqSearch(int z[];int key;int n)
    long start = System.currentTimeMillis();
    int count=0;
    int ans=-1;
    for(int i=0;i<n;i++)
    if z=key
    count++
    {ans=i
    break;}
    return ans;
    long elapsed = System.currentTimeMillis() - start;
    System.out.print("Execution Time:" + elapsed);
    System.out.print("# of Basic Operations:" + count);
    public int binSearch(int z[];int first;int last;int key)
    long start = System.currentTimeMillis();
    int count=0;
    if(last><first){
    count++;
    index=-1;
    else
    count++;
    int mid=(first+last)/2
    if(ket=z[mid]{
    index=mid;
    else
    if(key><z[mid]){
    index = binSearch(z[];first;mid-1;key);
    else
    index=binSearch(z[];mid+1;last;key);
    return index;
    long elapsed = System.currentTimeMillis() - start;
    System.out.print("Execution Time:" + elapsed);
    System.out.print("# of Basic Operations:" + count);
    and what about the dukes, offer 10 (never to be awarded, of course)
    do this, then sit back and watch the replies roll in.

  • I need help in converting a pdf to a fillable form in my adobe

    I need help in converting a pdf to a fillable form in my adobe

    "Adobe" is a company. If you mean "Adobe Reader" then you can't (at least not easily). You need Adobe Acrobat for that.

  • My old iMac and OS 10.4 will not accept the New iTunes Version 10 application and I can't get past the screen offering to download iTunes 10.  This is wrong and I need help getting past this situation. Help!

    My old iMac and OS 10.4 will not accept the New iTunes Version 10 application and I can't get past the screen offering to download iTunes 10.  This is wrong and I need help getting past this situation. Help!

    Sure, you can get around it if you don't need the newest version of iTunes. I still use version 7.5 because the newer versions didn't strike me as offering anything I needed.
    If you do need a version 10-something then you will have to upgrade your operating system to Leopard (fi your computer will support it) at least.  If you need 10.5 for some reason then there's no getting around it, you will have to buy a new computer.

  • HT1206 I can't log into the Itunes store.  I type in my Apple ID and my password and the message "This Apple ID cannot be used for the iTunes Store." "Enter another Apple ID."  I need help on fixing this.

    I can't log into the Itunes store.  I type in my Apple ID and my password and the message "This Apple ID cannot be used for the iTunes Store." "Enter another Apple ID."  I need help on fixing this.

    Yeah I'm starting to see a ton of forums posts right now about the same thing :/ I wonder what's going on

  • I need help to convert a string to date and time

    Good aft,
    1.How can i get a date from the user input thro' Frames?
    2.How to parse it to the date object(I need to include java.util.Date but for the database i need to include java.sql.*,if i do so, i have error as
    found:java.util.Date
    Required:java.sql.Date)
    3.How to insert into the database
    The same i need help to insert time into database?
    I need solution and explanation...
    Reply me immediately...
    If u send me the code, its better to me.

    Hello,
    The best way is to use the HEX to decimal coversion VI in the string pallette. Then, write this decimal directly to your chart. If you are doing it a point at a time put it into a while loop.
    Doug

  • I need help to convert photos in the .swf format to a format that will open on iOS

    I need help converting photos in the .swf format to a format that will work on my Mac.  Thanks

    SWF is a Flash file that should be able to be opened with your web browser on your Mac. Probably not on iOS though.
    You will likely need to find the source file for the application that created the SWF and the image will be in that. You could then export/extract the image and have it as a stand alone file.
    It does look like there are applications that can do what you are looking for though: https://www.google.com/search?q=SWF+to+JPG

  • Need help on converting milliseconds to string.

    Hi,
    I am really confused by GMT. I need to convert milliseconds to string. A millisecond represents the date of 2/14/02 22:37:27 GMT. I formatted the string so that output is in the right format. But I kept getting a time string of "02/14/02 16:37:27". How do I get a string of "02/14/02 22:37:27" instead? My local time zone is GMT-6.
    Thank you very much.

    Is it a Calendar object you are using? If so it look slike there is a method called setTimeZone(). Its clear by your output that you are getting a local time for your zone so you just need to change the zone for that particular Calendar object (I think I never tried it)

  • Need help to convert GUI to command line

    Hi Guys ,
    Need some help with respect to scripting
    I am working on a Unix platform(sun), where in I am asked to invoke table menu via command line which has lots of option like STATUS, REPORT ….
    It goes like this
    After login in to unix box , I am entering “yct”
    It brings me a table with lot of option , I need to scroll down and then select “Report “ which display the report
    Is it possible to for me to convert this entire action in to a single unix commad or can i call it via script. 

    Actually WIndows NT has always run Unix (Posix) which was the original Linux before Linux.  Posix used to come on the CD/Disk set.  MS eventually dropped Posix from the box.  Now we just load almost any version Linux into a VM.
    I am surprised at how many new young users think that Unix is a Microsoft product. THey think theonly competitor is Apple so Unix must be Microsoft. Funny thing that Mac is Unix. OS/X was named for Jobs advanced version of Unix called "neXt" or "X".
    The board bought it but wouldn't allow the name.
    The problem that jobs solved with Unix was getting rid of X-Windows in favor of the Mac Windows API on Unix.   Mac API is very close to the WIndows API.  They share the same philosophy.   X-Windows is completely backwards and very
    difficult to design with.
    It is interesting that in Unix the users question has an answer evry much like a PowerShell solution.  We would pipe the data to a formatter which would generate a table (Format-Table) or a list (Format-List).
    I no longer remember the commands to convert a data stream or data file into a report. 
    cat?  grep? list? mtable?
    ¯\_(ツ)_/¯

  • Need help on fixing this bug

    Hello!
    I have my cod which needs some bug fixing. This is a drag and drop application where the user will drap the correct answer on corresponding targets. My problem here is, when one target is already occupied by an object i can still drop another object there, which shouldn't. can you please help me fix this?
    thanks in advance!
    Sincerely.
    Milo
    Here's my code:
    var startX: Number;
    var startY: Number;
    var correct: Number = 0;
    var attempt: Number = 0;
    var currentlyDragged:MovieClip;
    // collection of objects stored in array
    // so that you can reference them programmatically
    var objects:Array = [at1, in1, in2, in3, in4, in5, in6, in7, in8, on1, on2];
    activateObjects();
    // assigns listeners and other functionality to the objects in objects array
    function activateObjects():void {
         for each(var mc:MovieClip in objects) {
              mc.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
              mc.buttonMode = true;
              // assign drop targets based on names
              switch(String(mc.name).substring(0, 2)) {
                   case "at":
                        mc.dropTargets = [targetAT1];
                   break;
                   case "in":
                        mc.dropTargets = [targetIN1, targetIN2, targetIN3, targetIN4, targetIN5, targetIN6, targetIN7, targetIN8];
                   break;
                   case "on":
                        mc.dropTargets = [targetON1, targetON2];
                   break;
    function pickObject(e:MouseEvent):void {
         currentlyDragged = MovieClip(e.currentTarget);
         currentlyDragged.startDrag();
         startX = currentlyDragged.x;
         startY = currentlyDragged.y;
         stage.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    function dropObject(e:MouseEvent):void {
         stage.removeEventListener(MouseEvent.MOUSE_UP, dropObject);
         stopDrag();
         var droppedOn:MovieClip;
         if (currentlyDragged.dropTarget) {
              // loop through targets belonging to the currently dragged clip
              for each(var mc:MovieClip in currentlyDragged.dropTargets) {
                   if (currentlyDragged.hitTestObject(mc)) {
                        // get the target
                        droppedOn = mc;
                        currentlyDragged.removeEventListener(MouseEvent.MOUSE_DOWN, pickObject);
                        currentlyDragged.buttonMode = false;
                        currentlyDragged.x = droppedOn.x;
                        currentlyDragged.y = droppedOn.y;
                        correct++;
                        correctCounter.text = String(correct);
                        // stop loop - it is not necessary to continue
                        break;
         attempt++;
         attemptCounter.text = String(attempt);
         // return to the initial position if there is no hit
         if (!droppedOn) {
            currentlyDragged.x = startX;
            currentlyDragged.y = startY;
         if (correct == objects.length) {
              var congrats:CongratsMC = new CongratsMC();
              // place i in the middle of the screen
              congrats.x = (stage.stageWidth - congrats.width) * .5;
              congrats.y = (stage.stageHeight - congrats.height) * .5;
              addChild(congrats);

    Try the code below.
    Also, use int instead of Number whenever possible - it is smaller and faster.
    import flash.display.MovieClip;
    import flash.display.Sprite;
    var startX:Number;
    var startY:Number;
    var correct:int = 0;
    var attempt:int = 0;
    var currentlyDragged:MovieClip;
    // collection of objects stored in array
    // so that you can reference them programmatically
    var objects:Array = [at1, in1, in2, in3, in4, in5, in6, in7, in8, on1, on2];
    var congrats = new CongratsMC();
    congrats.addEventListener("close", closeCongrats);
    activateObjects();
    // assigns listeners and other functionality to the objects in objects array
    function activateObjects():void {
         for each(var mc:MovieClip in objects) {
              mc.addEventListener(MouseEvent.MOUSE_DOWN, pickObject);
              mc.buttonMode = true;
              // assign drop targets based on names
              switch(String(mc.name).substring(0, 2)) {
                   case "at":
                        mc.dropTargets = [targetAT1];
                   break;
                   case "in":
                        mc.dropTargets = [targetIN1, targetIN2, targetIN3, targetIN4, targetIN5, targetIN6, targetIN7, targetIN8];
                   break;
                   case "on":
                        mc.dropTargets = [targetON1, targetON2];
                   break;
    function pickObject(e:MouseEvent):void {
         currentlyDragged = MovieClip(e.currentTarget);
         currentlyDragged.startDrag();
         startX = currentlyDragged.x;
         startY = currentlyDragged.y;
         stage.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    function dropObject(e:MouseEvent):void {
         stage.removeEventListener(MouseEvent.MOUSE_UP, dropObject);
         stopDrag();
         var droppedOn:MovieClip;
         correctCounter.text = String(correct);
         if (currentlyDragged.dropTarget) {
              // loop through targets belonging to the currently dragged clip
              for each(var mc:MovieClip in currentlyDragged.dropTargets) {
                   if (currentlyDragged.hitTestObject(mc)&& mc.notUsed) {
                        // get the target
                        droppedOn = mc;
                        mc.notUsed = false;
                        currentlyDragged.removeEventListener(MouseEvent.MOUSE_DOWN, pickObject);
                        currentlyDragged.buttonMode = false;
                        currentlyDragged.x = droppedOn.x;
                        currentlyDragged.y = droppedOn.y;
                        correct++;
                        correctCounter.text = String(correct);
                        removeTarget(droppedOn);
                        // stop loop - it is not necessary to continue
                        break;
         attempt++;
         attemptCounter.text = String(attempt);
         // return to the initial position if there is no hit
         if (!droppedOn) {
            currentlyDragged.x = startX;
            currentlyDragged.y = startY;
         if (correct == objects.length) {
              // place i in the middle of the screen
              congrats.x = (stage.stageWidth - congrats.width) * .5;
              congrats.y = (stage.stageHeight - congrats.height) * .5;
              addChild(congrats);
    function removeTarget(target:Sprite):void {
         var i:int = 0;
         for each(var mc:MovieClip in objects) {
              for (i = 0; i < mc.dropTargets.length; i++) {
                   if (mc.dropTargets[i] == target) {
                        mc.dropTargets.splice(i, 1);
    function closeCongrats(e:Event):void {
         removeChild(congrats);

  • Need help on Oracle Report format

    Hi,
    I need help on Oracle Reports. I am generating a report in excel sheet. I have a column which is 13 digit number (In database it is CHAR datatype). In excel sheet it showing some thing like 9.78381E+12. I want to show complete number like 9783805591331.
    Also sometimes leading zero's are not showing when my column values is something like 0098794859583. I need to show the leading zero's as well in excel without losing them.
    Below are the parameters i am using for the report
    DESFORMAT=SPREADSHEET AND DESTYPE=FILE
    My Oracle 9i developer version.
    Any help on this would be much appreciated.
    Thanks
    Kishore

    An additional quote string ' character with the number field will solve this problem but if u want to display this field in report then it will look ugly
    '''||yourfield from table; check ur regional settings also
    plz mark it helpful correct if it is

Maybe you are looking for

  • Error while creating SC: Internal Error - termination type TH_RES_FREE

    Hi I encountered this error while creating a SC. All attributes for this user are maintained and the "check user" transaction does not give any error. Amol Mate Error when processing your request What has happened? The URL http://punhjwsapsrm:8000/sa

  • Hardware Requirement for Solaris 8 Installation

    Hi, Can anyone give me the hardware requirements for Solaris 8 Installation. I need to install the following patches too.. C++Runtime 108434-12 Linker 109147-21 J2SE Solaris8 (patch cluster) SUNWxwfnt (X Window System platform fonts) SUNWilof (ISO-88

  • Cannot connect to internet with huawei e220 after plugged in Ipod touch

    Guys, I have serious problem. I have a vodafone (spain) branded huawei E220 usb 3G modem. It used to work fine until i plugged in my Ipod touch. From then on the connecting app (Vodafone Mobile Connect) will hung up using 55% of CPU capacity. This is

  • QVPN DOESN´T WORK

    I have just installed an RV042W router at my small business, and am trying to connect to it via QVPN from home. I have been unable to do so, no matter what I try. Pertinent information: I can connect to the router via Remote Management just fine, so

  • SNMP counter problem

    Hi, i configured management program to poll MIB OID 1.3.6.1.4.1.9.10.19.1.1.4(cpmActiveDS0s;The number of DS0s that are currently in use.) Everything ok and i got what i want. But some polled routers increment counter and values rises day by day. Aft