Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Convert Calendar to String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert Calendar to String" Watch "Convert Calendar to String" New topic
Author

Convert Calendar to String

Bob Smith
Greenhorn

Joined: Sep 10, 2008
Posts: 12
How do I convert a Calendar to a String? I would like it in the following format MM/DD/YYYY.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Calendar.getTime() + (Simple)DateFormat is the way to go.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Bob Smith
Greenhorn

Joined: Sep 10, 2008
Posts: 12
Thanks, I got it to work

String strdate = null;

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

if (calendardate != null) {
strdate = sdf.format(calendardate.getTime());
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert Calendar to String
 
Similar Threads
converting date string into Calendar.Day of Year
xsd datetime format
Comparison between two dates
Date Formate Problem
Need to get a Day from Date