I'm trying to print a date with the following format:
"HHmmssff"
I'm using SimpleDateFormatter.
It fails because it can't recognize "ff".
Is there another formatter that can?
Or any other way to do it?
If you are looking for printing second in fractions (milliseconds), this example will be helpful.
public class DateFormatter {
public static void main(String[] args) {
Date date = Calendar.getInstance().getTime();
DateFormat formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy, hh:mm:ss.SSS a");
String today = formatter.format(date);
System.out.println("Today : " + today);
}
}
Output: Today : Tuesday, 24 May 2011, 07:23:30.627 PM
You see SSS in the formatter returns fractions of seconds for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With