Guest User

Untitled

a guest
Oct 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. public class DateFormater {
  2.  
  3. public static void main(String[] args) throws IOException {
  4.  
  5. if(args.length == 0){
  6. System.out.println("Faltan argumentos");
  7. return;
  8. }
  9.  
  10. try {
  11. System.out.println("Leyendo Archivos de ConfiguraciĆ³n ... ");
  12. Configuration conf = new Configuration("../resources/Configuracion.json");
  13.  
  14. final String origin = (String) conf.getJson().get("origen") +args[0];
  15. final String destiny = (String) conf.getJson().get("destino")+args[1];
  16. FileInputStream fstream = new FileInputStream(origin);
  17. FileWriter writer = new FileWriter(destiny);
  18. BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
  19. String strLine;
  20.  
  21. while ((strLine = br.readLine()) != null) {
  22. if(strLine.contains("Fecha de Emision: ")){
  23. String date = strLine.substring(83,93);
  24. SimpleDateFormat format = new SimpleDateFormat("MM/dd/YYYY");
  25. String dateString = format.format(new Date(date));
  26. String newDate = strLine.replace(date, dateString);
  27. writer.write(newDate+"n");
  28. }
  29. else{
  30. writer.write(strLine+"n");
  31. }
  32. }
  33. br.close();
  34. writer.close();
  35. System.out.println("El programa ha finalizado con exito");
  36. System.out.println("El nuevo archivo ha sido generado en " + destiny);
  37. } catch (FileNotFoundException ex) {
  38. Logger.getLogger(DateFormater.class.getName()).log(Level.SEVERE, null, ex);
  39. } catch (ParseException ex) {
  40. Logger.getLogger(DateFormater.class.getName()).log(Level.SEVERE, null, ex);
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment