Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Java Util Package Code Examples

Create SimpleDateFormats from a string read from a file

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
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(); } }