Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
"I'm not back." - Bill Harding, Twister
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
Think about making a little elapsed time class. This could be a fun OO exercise. Could you make these print true?
How about another constructor with before & after times in milliseconds? Should you have days() and weeks() methods? (I'll vote NO for months() or anything bigger.) What would a good toString() implementation say?
[ November 22, 2005: Message edited by: Stan James ]
Originally posted by csie clare:
import java.text.SimpleDateFormat;
import java.util.Date;
public class Convert {
public String getDateTime(String pattern){
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(new Date());
}
/**
* @param args
*/
public static void main(String[] args) {
Convert con = new Convert();
System.out.println(con.getDateTime("hh:mm:ss"));
}
}
[ November 23, 2005: Message edited by: csie clare ]
If I were going to write something to do this I think I'd create a class that can be instantiated with milliseconds and then could return milliseconds, seconds, minutes, hours. You could then create a formatter capable of converting that to a specific format such as HH:MM:SS, HHHH:MM:SS. I suppose you could add in support for days, weeks and months too.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi