Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DateFormater {
- public static void main(String[] args) throws IOException {
- if(args.length == 0){
- System.out.println("Faltan argumentos");
- return;
- }
- try {
- System.out.println("Leyendo Archivos de ConfiguraciĆ³n ... ");
- Configuration conf = new Configuration("../resources/Configuracion.json");
- final String origin = (String) conf.getJson().get("origen") +args[0];
- final String destiny = (String) conf.getJson().get("destino")+args[1];
- FileInputStream fstream = new FileInputStream(origin);
- FileWriter writer = new FileWriter(destiny);
- BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
- String strLine;
- while ((strLine = br.readLine()) != null) {
- if(strLine.contains("Fecha de Emision: ")){
- String date = strLine.substring(83,93);
- SimpleDateFormat format = new SimpleDateFormat("MM/dd/YYYY");
- String dateString = format.format(new Date(date));
- String newDate = strLine.replace(date, dateString);
- writer.write(newDate+"n");
- }
- else{
- writer.write(strLine+"n");
- }
- }
- br.close();
- writer.close();
- System.out.println("El programa ha finalizado con exito");
- System.out.println("El nuevo archivo ha sido generado en " + destiny);
- } catch (FileNotFoundException ex) {
- Logger.getLogger(DateFormater.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ParseException ex) {
- Logger.getLogger(DateFormater.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Add Comment
Please, Sign In to add comment