clive vh

Greenhorn
+ Follow
since Sep 28, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by clive vh

Joel - have a look at the class SimpleDateFormat.
The easiest way of performing mathematical operations on dates and times is to use the GregorianCalendar class.
Say you have an instance of the class as follows:
-------------------------------------------------------------------
//one instance of GregorianCalendar holds the curent time, the other will hold the current time plus 30 minutes

currentTimeGC = new GregorianCalendar();
currentTimePlusThirtyGC = new GregorianCalendar();
//note that Calendar is a superclass of GregorianCalendar, therefore the methods of Calendar are available to GergorianCalendar.
currentTimePlusThirtyGC.add( Calendar.MINUTE +30);
//use SimpleDateFormat so you get rid of the milliseconds etc.
SimpleDateFormat sdf = new SimpleDateFormat( "hh:mm:ss" );
//Now format the objects and print them out
String strCurrentTimeGC = sdf.format( currentTimeGC );
String strCurrentTimePlusThirtyGC = sdf.format( currentTimePlusThirtyGC );
System.out.println("The current time is " + strCurrentTimeGC);
System.out.println("The time after adding 30 minutes is " + strCurrentTimePlusThirtyGC);
22 years ago
Thanks very much Manfred, this is just fine. Thanks also to JavaRanch for a really useful site
Clive
22 years ago
Good day all
I'm using the Sun JDK1.3.0_02 on Windows 2000. I need to:
1) get the current date in the format dd/mm/yyyy (call this the deal_date)
2) add 30 days to the above (call the result expiry_date)
3) convert both deal_date and expiry_date to Strings
4) when calling expiry_date from a database, compare it to the current (system) date to see if the difference is greater than 30 days.
Please could somone give me the cleanest possible method of doing this. I have grappled with the classes Calendar, GregorianCalendar, Date and DateFormat until my head hurts. I would prefer to use the standard classes found in the JDK rather than adding additional classes.
many thanks.
Clive
22 years ago
Thanks Jason, this works fine - thanks also to Cindy and JavaRanch for a great site!
Till next time,
Clive.
22 years ago
Can anyone post what is the score they got in real exam as well as the socre they goet in mock exam like whizlabs,JWeb+, or JavaRanch.
I think that will be very helpful for people to know if they are ready to take the exam or not.
Thanks.
Hi there
I have a small application (Java and JSP) that, amongst other things, displays a client's portfolio details - funds, stocks and cash, using WML as the markup language.
A client can have multiple portfolios. I am currently using hashtables to display the portfolio names, then the total value of the portfolio, then break the portfolio value down into separate totals for funds, stocks and cash.
I am having trouble with my second hashtable, which displays the total portfolio value. For a given portfolio id, there can be only one record in the database. The portfolio id is the primary key.
The results of the SQL SELECT statement (which works correctly as a straight database query) are placed into a ResultSet by a bean called PortfolioBean. The short form of this name in the code pasted below is simply 'portfolio'. The contents of the ResultSet are then placed into a hashtable called portfolio_breakdown_hashtable.
The JSP page calls a get method on a holding class called PortfolioBreakdown, which contains methods returning the elements of the hashtable.
When I run the JSP, the value returned for any of the amounts (stocks, funds or cash) is 0.0 If I call the method getPortfolioName, nothing at all appears on the screen (note: 'null' is NOT displayed). I am pretty confident that the hashtable does have elements in it, as otherwise I would not get the card titled "display" appear on screen. I have a feeling that the problem is that I have to use the Hashtable method nextElement, when in fact there is only one element in the hashtable - or am I wrong? Maybe my understanding of what constitutes an element is wrong? Please could you have a look at my code and advise. Maybe there is another approach altogether that I should be using? If possible, however, I would like to continue using hashtables.
Many thanks,
Clive.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
< relevant portion of JSP page>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++==

< relevant portion of PortfolioBean.java>

+++++++++++++++++++++++++++++++++++++++++++++
< PortfolioBreakdown.java>

(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited September 28, 2001).]
22 years ago