0

I think I've pretty well got a hold on Dates now. So, I created a new object in a class and I assigned it a Date property, and I told it to print the Date property. It does, but just like it would normally do in C#, it presents a Date and a Time. But in C#, you can change that by something like this:

 Console.WriteLine("myDate = {0}:d", myDate);

And the :d changes it to just a normal Date format without the time. Is there any similar way to do that in Java?

prinsJoe
  • 683
  • 3
  • 7
  • 16
  • You can use [`MessageFormat`](http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html), or the [`Formatter`](http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#dt) syntax which is used in `PrintStream.printf()` and `String.format()`. – millimoose Nov 20 '13 at 16:45
  • possible duplicate of http://stackoverflow.com/questions/5683728/convert-java-util-date-to-string – akaya Nov 20 '13 at 16:48
  • Follow the link that @kaya gave, you need a DateFormat object to parse the date in *any* format that you want! – Klazen108 Nov 20 '13 at 16:56

0 Answers0