Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java time to DB2 timestamp conversion

807603Feb 19 2008 — edited Feb 19 2008
I want to convert current time to following format "2008-01-12 11:46:55.945000". I tried but I an not able to do. Could you pelase hlep me out or is there any easy way to do
		Calendar calendar = Calendar.getInstance();
		//2008-01-12 11:46:55.945000
		int year = calendar.get(Calendar.YEAR);
		int date = calendar.get(Calendar.DATE);
		int month = calendar.get(Calendar.MONTH);
		int hour = calendar.get(Calendar.HOUR);
		int minite = calendar.get(Calendar.MINUTE);
		int second = calendar.get(Calendar.SECOND);
		int millisecond = calendar.get(Calendar.MILLISECOND);
		String timestamp = year+"-"+date+"-"+month+" "+hour+":"+minite+":"+second+"."+millisecond;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2008
Added on Feb 19 2008
2 comments
4,021 views