programming-examples/java/Servlets_Session_Swing_Util/Create SimpleDateFormats from a string read from a.java

25 lines
858 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
Create SimpleDateFormats from a string read from a file
public class DateFormatFile {
/** Today's Date */
Date dNow = new Date();
public static void main(String[] args) throws IOException {
DateFormatFile df = new DateFormatFile();
BufferedReader is =
new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = is.readLine()) != null) {
df.process(line);
}
}
/** Use a SimpleDateFormat - based on arg - to print the date your way. */
protected void process(String arg) {
SimpleDateFormat formatter = new SimpleDateFormat(arg);
System.out.println("FORMAT: " + arg);
System.out.println("RESULT: " + formatter.format(dNow));
System.out.println();
}
}