DateFormatApp.java Source code

Java tutorial

Introduction

Here is the source code for DateFormatApp.java

Source

import java.text.SimpleDateFormat;
import java.util.Date;

class DateFormatApp {
    public static void main(String args[]) {
        String pattern = "'The year is '";
        pattern += "yyyy GG";
        pattern += "'.\nThe month is '";
        pattern += "MMMMMMMMM";
        pattern += "'.\nIt is '";
        pattern += "hh";
        pattern += "' o''clock '";
        pattern += "a, zzzz";
        pattern += "'.'";
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        String formattedDate = format.format(new Date());
        System.out.println(formattedDate);
    }
}