import java.io.*; import java.util.*; import pds.util.*; /** * Shows examples of using the PPITime package. */ class ExampleTime { public static void main(String[] args) { boolean good = false; if(args.length < 1) { System.out.println("Usage: Example name {...}"); System.out.println("Available examples are:"); System.out.println("\tParse: Test parsing of all time formats."); return; } if(args[0].compareToIgnoreCase("Parse") == 0) { good = true; Parse(args); } if(!good) System.out.println("Unknown example: " + args[0]); } /** * Parse time values in a variety of formats. * *
Source code: *
{@link PPITime} time = new PDSTime(); time.convert("1999-10-1T12:15:3.23", PPITime.PDS); System.out.println("Euro: " + time.format(PPITime.EURO)); System.out.println("PDS: " + time.format(PPITime.PDS)); *
*
*
To Run: * *
java example basic {label} *
* where {label} is the name of the label file to parse. * * @since 1.0 */ public static void Parse(String[] args) { PPITime time = new PPITime(); Date date; String buffer; System.out.println("== Parse and print time value ============"); buffer = "1024"; time.convert(PPITime.BINARY, buffer); System.out.println("Binary: " + buffer + " => Euro: " + time.format(PPITime.EURO)); System.out.println("Binary: " + buffer + " => Binary: " + time.format(PPITime.BINARY)); buffer = "1999"; time.convert(PPITime.PDS, buffer); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.EURO)); buffer = "1999-10-1"; time.convert(PPITime.PDS, buffer); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.EURO)); buffer = "1999-10-1T12"; time.convert(PPITime.PDS, buffer); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.EURO)); buffer = "1999-10-1T12:15"; time.convert(PPITime.PDS, buffer); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.EURO)); buffer = "1999-10-1T12:15:3.23"; time.convert(PPITime.PDS, buffer); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.EURO)); System.out.println("PDS: " + buffer + " => Euro: " + time.format(PPITime.PDS)); } }