Results 1 to 2 of 2
- 08-06-2007, 08:55 AM #1
Member
- Join Date
- Aug 2007
- Posts
- 5
- Rep Power
- 0
DateObject with the currentdate and Time specified by me
Iam getting the Timestamp from the data base and picking up the time from that :
and now i need to get the Date object with current date and with the above time.
I see that the Date object gives current date and time.
Can anybody suggest some thing for this.
Regards
Navap.
- 08-06-2007, 10:19 AM #2
Java Code:import java.text.*; import java.util.*; // Prepare a formatter. See SDF api for options. DateFormat df = new SimpleDateFormat("HHmm ddMMMyyyy"); // Get a Calendar instance. Calendar calendar = Calendar.getInstance(); System.out.println("now = " + df.format(calendar.getTime())); // Get the time. Assume time is in 24 hour format. String timeStr = "0612"; // 6:12 am int hours = Integer.parseInt(timeStr.substring(0,2)); int minutes = Integer.parseInt(timeStr.substring(2)); // Set this time into todays calendar date. calendar.set(Calendar.HOUR_OF_DAY, hours); calendar.set(Calendar.MINUTE, minutes); // Check the result. System.out.println("timeStamp = " + df.format(calendar.getTime()));
Similar Threads
-
Hello, first time here.
By ludragon in forum IntroductionsReplies: 2Last Post: 01-03-2008, 05:03 AM -
help with dates and time
By osval in forum New To JavaReplies: 3Last Post: 12-12-2007, 12:41 PM -
Time method
By carderne in forum New To JavaReplies: 5Last Post: 11-05-2007, 09:34 AM -
DataObject with the time given by me
By garinapavan in forum New To JavaReplies: 2Last Post: 08-07-2007, 06:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks