James Hewitt

Greenhorn
+ Follow
since Jul 09, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by James Hewitt

That seems to have sorted it out
thanks
James
23 years ago
I'm using JDBC to get values from a db2 database into a servlet. There is a column of integer values from which I want to retrieve the lowest value, but my sql isn't really up to it.
Is there an SQL statement which automatically returns the lowest value in a column?
Thanks,
James
I'm trying to do something really rather simple. I have an integer value and a float value which I want to multiply together to return another float value.
However, I get some odd decimal place effects, e.g.
67 * 0.35 gives 23.449999 instead of 23.45.
Why is this and how do I fix it?
Thanks,
James
23 years ago
Thanks for that. Got a java book. It really sucks.
Thanks,
James
23 years ago
Sorry it took me a while to get back to you. That's perfect. I'd resorted to using the getMinutes command, but that's depracated and inefficient. Your way is much better.
Thanks,
James
23 years ago
I want to run an if statement if an integer is between 2 values. I can do this by using two if statements, but can I avoid this repetition? I want something like this:
if(x > 1 AND x < 7){
out.println("x is between 1 and 7");
}
Clearly "and" isn't right, but what is? I note that you can seperate expressions in a "for" statement with ";", but this doesn't work in an if statement. Any ideas?
Thanks,
James
23 years ago
Sorry, that was very easy! Just worked it out myself. I'm getting better (slowly) at this.
Thanks,
James
23 years ago
I am writing a servlet which takes a value for a particular time from a database. This time is in the form of msec since epoch. What I want to do is convert this to the time of day for display in an html document. I have managed to return the full date/time value in html (i.e. including day, date, year, timezone), but all I actually want is the time of day, not the day/date/year etc. So, for example, I can create an html document with:
"Sun Jul 02 23:00:00 GMT+01:00 2001"
When all I actually want to display is:
"23:00"
Can anyone help me? Some sample code would be really useful.
Thanks in advance,
James
23 years ago
Very quick question - I want to convert the format of a date/time. I retrieve a msec value from a database, but instead of displaying it as a msec value in an html page, I want to display it as a normal time (e.g. 12:22). I have managed to display it as a full date and time (that is, Sun Jul 14 12:22:03 GMT 2001). However, I only want to show the time 12:22, not the date and timezone. How do I go about this.
Thanks,
James
23 years ago
Much better.
Thanks,
James
23 years ago
Nope, that doesn't seem to fix it. I reckon I'm making a really simple mistake, it's just not obvious to me. Just need to see a simple implementation in a piece of sample code, and I'm sure it'll all be clear.
23 years ago
Has anyone got an example of code which extracts a string from a properties file (i.e. a terxt file which contains pairs of values) and prints it out?
I'm having trouble getting such a servlet working.
thanks
James
23 years ago
Actually, k's are weird. H's do the trick much better
Thanks again,
James
23 years ago
Superb. The k's did it. Thanks very much for that.
James
23 years ago
Getting an interesting problem. I am retrieving a time from a database, stored in the form "Thu Jul 12 12:13:19 GMT+01:00 2001". In order to get it into my servlet, I import it as a string. Then, because I want to perform calculations on it, I convert it to date form. To do this, I:
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzzzzzzzzz yyyy");
and then,
java.util.Date d = sdf.parse(E);
where E is the string containing the date. This works perfectly for all times and dates with the exception of when the hour is "12" So, for example,
"Thu Jul 12 12:13:19 GMT+01:00 2001"
in the database, once imported and parsed is returned as:
"Thu Jul 12 00:13:19 GMT+01:00 2001"
That is, it interprets both the hours 00 and 12 in the database to be 00, midnight.
Any ideas how I get around this?
Thanks,
James
23 years ago