Example usage for java.text DateFormat format

List of usage examples for java.text DateFormat format

Introduction

In this page you can find the example usage for java.text DateFormat format.

Prototype

public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition);

Source Link

Document

Formats a Date into a date-time string.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getDateInstance();
    StringBuffer sb = new StringBuffer();

    sb = dateFormat.format(new Date(), sb, new FieldPosition(DateFormat.DAY_OF_WEEK_IN_MONTH_FIELD));
    System.out.println(sb);/*  www. j  av  a 2s  . c o m*/

}