Prints string given in text with current time. - Java java.util

Java examples for java.util:Time

Description

Prints string given in text with current time.

Demo Code


//package com.java2s;
import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        String text = "java2s.com";
        printTextWithTimeStamp(text);/*  ww  w.  j  av  a 2 s. co m*/
    }

    /**
     * Prints string given in text with current time.
     * @param text
     */
    public static void printTextWithTimeStamp(String text) {
        System.out.format("[%tr] %s \n", new Date(), text);
    }
}

Related Tutorials