Win a copy of Head First Android this week in the Android forum!

mike rich

+ Follow
since Jan 30, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mike rich

I need to calculate the number of days between 2 dates. I think I have confused myself beyond repair and I am seeking some advice. Below is a snip of my code. In a nutshell I am reading 2 string values, converting them to date and then I want to calculate the difference. any help would be appreciated.....
String ds1 = a[x].getinvoice().substring(date_start, last_paren);
String ds2 = a[x].getdate().trim();

DateFormat dt_parse1 = DateFormat.getDateInstance((DateFormat.SHORT));
DateFormat dt_parse2 = DateFormat.getDateInstance((DateFormat.SHORT));

Date d1 = dt_parse1.parse(ds1);
Date d2 = dt_parse1.parse(ds2);

SimpleDateFormat local_format1 = new SimpleDateFormat("MM/dd/yy");
SimpleDateFormat local_format2 = new SimpleDateFormat("MM/dd/yy");

System.out.println("New Date1: " + local_format1.format(d1));
System.out.println("New Date2: " + local_format1.format(d2));

/*Gregorian*/Calendar cal1 = new GregorianCalendar();

/*Gregorian*/Calendar cal2 = new GregorianCalendar();

System.out.println("New Date1 as calendar object: " + local_format1.format(cal1.getTime()));
System.out.println("New Date2 as calendar object: " + local_format1.format(cal2.getTime()));
System.out.println("********** " + (local_format1.format(cal1.getTime()) - local_format1.format(cal2.getTime())));

catch (ParseException p)
19 years ago
I have read in 2 data files into 2 'Record' object arrays. I need to loop through the values in each to determine combinations based on a set of logic. I have created a new object called Merge that takes in an array of each of the Record objects (Record1 [] and Record2 []). The issue that I have is that in order to process the logic rules I must determine if each of the Record2 objects has 2 fields/variables or has 5 fields/variables. Once I know this I can determine the logic rules to process. How can I determine if a field/variable exists or not in a object? I feel like my use of 2 distinct constuctors (one for 2 fields and one for 5 fields) when I read from the text file is what the problem is. I was thinking maybe I should always expect 5 fields and then force in a null to the remaining 3 when there are only two fields to read in.
Please help - I am at the end of my rope. I am new at this and now that I have most of the heavy lifting of reading a file into an array of objects done I feel like I can't reach a conclusion...... So close, yet still so far!!!
19 years ago