Java examples for java.util:Time
Prints string given in text with current time.
//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); } }