Create SimpleDateFormats from a string read from a file
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
/** Create SimpleDateFormats from a string read from a file */
publicclass DateFormatFile {
/** Today's Date */
Date dNow = new Date();
publicstaticvoid 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. */
protectedvoid process(String arg) {
SimpleDateFormat formatter = new SimpleDateFormat(arg);
System.out.println("FORMAT: " + arg);
System.out.println("RESULT: " + formatter.format(dNow));
System.out.println();
}
}