fork(1) download
  1. // from https://i...content-available-to-author-only...e.com/TaR29j
  2. /* package whatever; // don't place package name! */
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Date;
  7. import java.text.SimpleDateFormat;
  8. import java.text.*;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class TimeSheet
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. //Scanner myObj = new Scanner(System.in); // Create a Scanner object
  16.  
  17. Scanner myObj = new Scanner(System.in); // use myObj so you don't have to change it if you choose to use hard-wired inputs
  18.  
  19. // https://w...content-available-to-author-only...t.com/how-to-format-date-using-printf-method-in-java
  20. Date dateObj = new Date();
  21.  
  22. // https://stackoverflow.com/posts/39066917/revisions
  23. SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d, yyyy");
  24.  
  25. System.out.println("From \"https://c...content-available-to-author-only...e.com/pwm/action/mobileGetTimesheetPunches\"");
  26.  
  27. //stackoverflow/questions/2296685/how-to-read-input-with-multiple-lines-in-java
  28. //stackoverflow/questions/56887493/how-to-take-multi-line-input-in-java search:HashmatWarrior
  29. while(myObj.hasNext())
  30. {
  31. String gottaFix = myObj.nextLine();
  32. String[] dateString = new String[2];
  33. String header = "Type Status Time Hours";
  34. String hours;
  35. String[] punch = new String[4];
  36.  
  37. if(!gottaFix.isEmpty())
  38. {
  39. if(gottaFix.contains("Punches:"))
  40. {
  41. dateString = gottaFix.split(": ");
  42. dateObj = sdf.parse(dateString[1]);
  43.  
  44. System.out.printf("%ta", dateObj); // Sun
  45. System.out.printf(" %tm", dateObj); // date
  46. System.out.printf("/%te", dateObj); // date
  47.  
  48. System.out.print(", scheduledTime");
  49.  
  50. /*System.out.printf("Date: %td%n", dateObj); System.out.printf("Month: %tm%n", dateObj); System.out.printf("Year: %ty%n", dateObj); System.out.printf("getTime(): "+dateObj);*/
  51. }
  52.  
  53. else if(gottaFix.contains("PM"))
  54. {
  55. punch = gottaFix.split("\t");
  56. System.out.print(", ");
  57. System.out.print(punch[2].replaceAll(" \\DM", ""));
  58.  
  59. if(punch[0].equals("ES"))
  60. {
  61. if(punch[1].equals("Edited"))
  62. { System.out.println("/, (bank run); ");}
  63. else
  64. { System.out.println(", no bank run; ");}
  65. }
  66. }
  67. }
  68.  
  69. //else
  70. {
  71.  
  72. }
  73. }
  74. }
  75. }
Success #stdin #stdout 0.21s 57012KB
stdin
Punches: Fri Jun 17, 2022
Type	Status	Time	Hours
SS	Normal	5:34 PM	3:32
SB	Normal	9:06 PM	0:12
EB	Normal	9:18 PM	1:49
ES	Normal	11:07 PM

Punches: Sat Jun 18, 2022
Type	Status	Time	Hours
SS	Normal	5:33 PM	4:01
SB	Normal	9:34 PM	0:12
EB	Normal	9:46 PM	1:10
ES	Normal	10:56 PM	

Punches: Sun Jun 19, 2022
Type	Status	Time	Hours
SS	Normal	3:40 PM	3:12
SB	Normal	6:52 PM	0:13
EB	Normal	7:05 PM	1:37
ES	Normal	8:42 PM	

Punches: Tue Jun 21, 2022
Type	Status	Time	Hours
SS	Normal	5:30 PM	3:40
SB	Normal	9:10 PM	0:13
EB	Normal	9:23 PM	1:14
ES	Normal	10:37 PM
stdout
From "https://c...content-available-to-author-only...e.com/pwm/action/mobileGetTimesheetPunches"
Fri 06/17, scheduledTime, 5:34, 9:06, 9:18, 11:07, no bank run; 
Sat 06/18, scheduledTime, 5:33, 9:34, 9:46, 10:56, no bank run; 
Sun 06/19, scheduledTime, 3:40, 6:52, 7:05, 8:42, no bank run; 
Tue 06/21, scheduledTime, 5:30, 9:10, 9:23, 10:37, no bank run;