Convert Date to String in Java

Convert Date to String in Java is a continuation of the previous post. Here we show you how to convert date to string in java by creating a complete example program.

Let’s begin to create example program for Date to String conversion:

In this example I am taking current date via Calendar instance as an input and converting into a String. We will get the output String in various format too.

Run above main and the output will display like this:

Convert Date to String in Java

Now, I share with you a complete code of Date to String conversion. The below function converts a Date to a String. It is taking two parammeters as input, one is Date object and the other is format string so you can custom your format as you want.

That’s it on the tutorial Convert Date to String in Java.

Leave a Comment


Please share it if you found this useful
Hide Buttons