Global Rich List
#
I found it interesting that someone making $200,000 or more a year is among the top 108,000 richest people on Earth. That's a pretty small number of people
I found it interesting that someone making $200,000 or more a year is among the top 108,000 richest people on Earth. That's a pretty small number of people
String zip = new String(req.getParameter("ZIP"));
// several lines deleted for clarity
StringTokenizer ziptk = new StringTokenizer(zip, "-");
int zipcount = ziptk.countTokens();
String zip1 = null;
String zip2 = null;
switch (zipcount) {
case 2:
while (ziptk.hasMoreElements()) {
zip1 = (String) ziptk.nextElement();
userBean.setZip(zip1);
zip2 = (String) ziptk.nextElement();
userBean.setZip1(zip2);
}
case 1:
while (ziptk.hasMoreElements()) {
zip1 = (String) ziptk.nextElement();
userBean.setZip(zip1);
userBean.setZip1("");
}
}
The poster has a hilarious deconstruction of this code in his comment, but I read it and said, "Hell, we've got worse code in our software, written by American programmers!"
Check it out. This code parses American-style dates from the web.
int day1 = 1;
int month1 = 0;
int year1 = 1970;
// Parse start date
StringTokenizer st = new StringTokenizer(fromDate, "/");
if (st.countTokens() == 3) {
Integer i = new Integer(st.nextToken());
month1 = i.intValue();
month1--; //months are numbered from 0 to 11
i = new Integer(st.nextToken());
day1 = i.intValue();
i = new Integer(st.nextToken());
year1 = i.intValue();
}
GregorianCalendar cal = new GregorianCalendar(year1, month1, day1, 0, 0, 0);
Date startDate = cal.getTime();
int day2 = 1;
int month2 = 0;
int year2 = 1970;
st = new StringTokenizer(toDate, "/");
if (st.countTokens() == 3) {
Integer i = new Integer(st.nextToken());
month2 = i.intValue();
month2--; //months are numbered from 0 to 11
i = new Integer(st.nextToken());
day2 = i.intValue();
i = new Integer(st.nextToken());
year2 = i.intValue();
}
cal = new GregorianCalendar(year2, month2, day2, 23, 59, 59);
Date endDate = cal.getTime();
God knows my own code isn't perfect, but there is just no substitute for knowing the libraries of the system you're using -- where ever you're from.