473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Determining which numeric value in a string is larger does not work.

1
Trying to parse some Java code in a middleware tool but somehow determining which numeric value in a string is larger does not work.

The input variables are:
- TRDT and VLDT are strings and contain the date in format YYYYMMDD
- OWOVHE_R contains a string read from a file
- oOWOVHE contains the output value
- iOWOVHE contains the input value

The below JAVA code is called for every record read of a file and the purpose is to determine which value to take from the table (the valid date VLDT needs to be smaller or equal to the transaction date TRDT).

Code:
Expand|Select|Wrap|Line Numbers
  1. Integer nTRDT = Integer.parseInt(TRDT.trim());
  2. Integer nVLDT = Integer.parseInt(VLDT.trim());
  3.  
  4. if (nTRDT >= nVLDT) 
  5. {oOWOVHE = OWOVHE_R;} 
  6. else 
  7. {oOWOVHE = iOWOVHE;}

gives this result:
TRDT=20130307; VLDT=20120101; OWOVHE_R=7.500000; OWOVHE=7.500000
TRDT=20130307; VLDT=20130101; OWOVHE_R=6.000000; OWOVHE=6.000000
TRDT=20130307; VLDT=20131201; OWOVHE_R=9.000000; OWOVHE=9.000000

For the last OWEVHE the value should remain 6 as TRDT is smaller then VLDT.

What is wrong in the comparison? Should I not make then Integers? But how can I compare strings in a larger then?
Mar 8 '13 #1
2 1463
Rabbit
12,516 Expert Mod 8TB
There's not much we can help with if we don't know how and where oOWOVHE, OWOVHE_R, and iOWOVHE are defined.
Mar 8 '13 #2
r035198x
13,262 8TB
No, the problem is that you are reading a date as an integer. Convert the values to dates first using

Expand|Select|Wrap|Line Numbers
  1. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyMMdd");
  2. if(dateFormat.parse(TRDT.trim()).after(dateFormat.parse(VLDT.trim()))) {
  3.          // do your TRDT is greater logic here  
  4.         } 
Mar 8 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iona | last post by:
okay.. this should be long.. I made up a table in database with access consists of columns with text type. Some of them I put in data with numeric value and some of them I put in "Unlimited" as...
5
by: ief | last post by:
hi all, i'm trying to check the length of a numeric value in a string. this is what i need to do: I have a string "Mystring (253)" and a string "SecondString (31548745754)" Now i have to...
0
by: Bing Wu | last post by:
(copied to comp.databases.ibm-db2) Greetings, Settings: DBD::DB2 v0.76 DBI v1.38 Perl v5.8.0 IBM DB2 ESE v8.1 sp 4
2
by: mdeaver2003 | last post by:
I'm trying to output a double using a precision that varies, governed by the value of a precision variable. In C I can do it like this: double pi = 3.14159; int prec = 4; printf( "%.*f",...
4
by: Surek | last post by:
I need to get the numeric value alone in a string which includes special characters and alphabets. eg string: vism/t1-1/1 Should retrieve the first numeric value from the given string.
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
6
by: frohlinger | last post by:
Hi, I need to perform some numeric calculations on a numeric float value, that is received as wstring. I would like to perform a check before converting the wstring to float, checking that indeed...
2
by: tron_23 | last post by:
hi, we use Toplink (TopLink - 4.6.0 (Build 417) with a DB2 Database 7.2. i know really old versions, but we could change to e newer one ;-) Sometimes we got some problems with update or insert...
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
4
by: Serman D. | last post by:
I would like to extract the first 6 digits of a numeric value (e.g. the string '123456' out of the numeric 1234567890123456789). I tried a combination of CAST and SUBSTR, but it seems I am not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.