Monday, September 23, 2013

Print formated Date

The example show various format to printf() Date object.

Print formated Date
Print formated Date

package java_time;

import java.util.Date;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class Java_Time {

    public static void main(String[] args) {
        Date now = new Date();

        System.out.println("default: " + now);
        System.out.printf("c: %tc\n", now);
        System.out.printf("D: %tD\n", now);
        System.out.printf("F: %tF\n", now);
        System.out.printf("r: %tr\n", now);
        System.out.printf("R: %tR\n", now);
        System.out.printf("T: %tT\n", now);
    }
}


No comments:

Post a Comment