[program-java] Re: String to int...

  • From: "Adrian Beech" <a.beech@xxxxxxxxxxxxxx>
  • To: <program-java@xxxxxxxxxxxxx>
  • Date: Fri, 25 Sep 2009 03:46:28 +1000

G?day Jim,

 

If I understand your question you want the two byte representation of the
integer value when the properties get method is called?  I?d suggest
checking out the java.text classes and perhaps using, if I recall right,
SimpleTextFormat.  I?ve done something similar in the past to display a
numeric value as a literal which was padded out with leading 0?s.

 

Cheers.

AB

 

From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Corbett, James
Sent: Thursday, 24 September 2009 11:06 PM
To: program-l@xxxxxxxxxxxxx; program-java@xxxxxxxxxxxxx
Subject: [program-java] String to int...

 

Sorry for the cross posting?. I have a COBOL copybook that defines an
element as Pic 9(5)? 

In my Java class I need to pass into my setter an integer for obvious
reasons. COBOL under the hood needs me to pass 00000 if the field is empty
because I'm actually building the com area at this point. If however the
field contains 999 I must still pass 00999 to fulfil the expected length?.

Ok, I have a string "00999" and need to convert it to an integer?. If I do
so, then the leading zeros are stripped off and my com area is 2 bytes
short?. Don't ask why or how it's the way it is?.

So, how do I manage this? 

Jim 

James M. Corbett 

Programmer / Analyst 
GST/HST Micros | Micros de la TPS/TVH 
Business Suite Assessing Systems (BSAS) 
Revenue and Accounting Systems Directorate (RASD) | Direction des Systèmes
de revenu et de comptabilité (DSRC) 
Information Technology Branch (ITB) | Direction générale de l'informatique
(DGI) 
Canada Revenue Agency | Agence du revenue du Canada 

(613) 941-1338 

"...Is a hippopotamus a hippopotamus, or just a really cool Opotamus?" 



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4453 (20090924) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Other related posts: