

|
 |
| Programming > Java Help > Re: True Intege... |
|
| << Topic |
< Post |
Post 7 of 28 Topic 16073 of 16269
|
Post > |
Topic >> |
Re: True Integer, Double
by Eric Sosman <Eric.Sosman@[EMAIL PROTECTED]
>
May 12, 2008 at 12:10 PM
| RC wrote:
> Eric Sosman wrote:
>
>>
>> Try explaining your notion of "TRUE" a bit more, and/or
>> consider using java.text.NumberFormat.
>
> I have some text data look like this (written by some
> retiree in Fortran)
> I need to convert them into XML file
>
> 1295 1 38.23 39.26 41.10 43.82 47.50 45.29
>
> Which means data starts from
> <event data="1995-12-1 00:00:00" value="38.23" />
> <event data="1995-12-1 06:00:00" value=" 39.26" />
> <event data="1995-12-1 12:00:00" value=" 41.10" />
> <event data="1995-12-1 18:00:00" value=" 43.82" />
> <event data="1995-12-2 00:00:00" value=" 47.50" />
> <event data="1995-12-2 06:00:00" value=" 45.29" />
>
> Now, you can see column 0 and column 1(1st and 2nd columns)
> are TRUE Integer.
> After column 2 (3rd column) are TRUE Double.
And your problem with this is ...? Perhaps I'm just being
dense today, but I don't see the difficulty. If you know that
columns 0 and 1 hold integers, use `new Integer(data[0])' or
`Integer.parseInt(data[1])'. For the remaining columns use
`new Double(data[2])' or `Double.parseDouble(data[3])'. In
both cases, you can try/catch NumberFormatException to detect
trouble if desired.
If you just want to rearrange the data and don't need to
validate it, most of the conversions may be unnecessary anyhow.
I guess you'll want to convert the first two columns and build
a Calendar object from them (it's easy to keep adding six-hour
intervals to a Calendar), but you could just take the remaining
columns as strings, outputting them in the same form they were
read.
--
Eric.Sosman@[EMAIL PROTECTED]


|
28 Posts in Topic:
|
RC <raymond.chui@[EMAI |
2008-05-12 10:50:14 |
|
"Kenneth P. Turvey&q |
2008-05-12 15:00:58 |
|
ram@[EMAIL PROTECTED]
(S |
2008-05-12 15:02:32 |
|
Eric Sosman <Eric.Sosm |
2008-05-12 11:10:01 |
|
RC <raymond.chui@[EMAI |
2008-05-12 11:35:06 |
|
ram@[EMAIL PROTECTED]
(S |
2008-05-12 15:45:53 |
|
Eric Sosman <Eric.Sosm |
2008-05-12 12:10:08 |
|
"John B. Matthews&qu |
2008-05-12 13:54:51 |
|
Wojtek <nowhere@[EMAIL |
2008-05-12 18:08:19 |
|
Mark Space <markspace@ |
2008-05-12 13:25:36 |
|
Eric Sosman <Eric.Sosm |
2008-05-12 16:45:30 |
|
Mark Space <markspace@ |
2008-05-12 17:21:11 |
|
=?ISO-8859-15?Q?Arne_Vajh |
2008-05-12 20:48:21 |
|
RC <raymond.chui@[EMAI |
2008-05-13 10:07:35 |
|
Eric Sosman <Eric.Sosm |
2008-05-13 10:46:37 |
|
Lew <lew@[EMAIL PROTEC |
2008-05-13 19:39:58 |
|
Lew <lew@[EMAIL PROTEC |
2008-05-13 19:39:04 |
|
=?ISO-8859-15?Q?Arne_Vajh |
2008-05-14 20:13:01 |
|
Tim Smith <reply_in_gr |
2008-05-17 22:21:30 |
|
=?ISO-8859-15?Q?Arne_Vajh |
2008-05-12 18:41:08 |
|
"Arved Sandstrom&quo |
2008-05-12 19:56:14 |
|
RedGrittyBrick <RedGri |
2008-05-12 22:54:27 |
|
=?ISO-8859-1?Q?Arne_Vajh= |
2008-05-12 18:45:46 |
|
Patricia Shanahan <pat |
2008-05-12 17:06:00 |
|
=?ISO-8859-1?Q?Arne_Vajh= |
2008-05-12 20:45:35 |
|
Tom Anderson <twic@[EM |
2008-05-18 13:29:15 |
|
Tim Smith <reply_in_gr |
2008-05-18 15:24:30 |
|
Roedy Green <see_websi |
2008-05-12 20:28:27 |
|
Post A Reply:

|
|
|
|