Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    public static String CurrentDateToDisplay() {
        String str = null;
        String outputPattern = "dd.MM.yyyy hh:mm a";
        try {

            Calendar c = Calendar.getInstance();
            SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
            str = outputFormat.format(c.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }
}