fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.* ;
  8. import java.time.format.* ;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15.  
  16. System.out.println(
  17. MonthDay // Represent a month & day-of-month, without a year.
  18. .from( // Extract a `MonthDay` from a `LocalDate`, omitting the year but keeping the month and day-of-month.
  19. LocalDate // Represent a date-only value, without time-of-day and without time zone.
  20. .parse( // Parse a string to get a `LocalDate`.
  21. "24/04/2019" , // FYI, better to use standard ISO 8601 formats rather than devising a custom format such as this.
  22. DateTimeFormatter.ofPattern( "dd/MM/uuuu" ) // Match the formatting pattern of your input strings.
  23. ) // Returns a `LocalDate`.
  24. ) // Returns a `MonthDay`.
  25. .format(
  26. DateTimeFormatter.ofPattern( "dd/MM" )
  27. )
  28. ) ;
  29.  
  30. }
  31. }
Success #stdin #stdout 0.16s 2184192KB
stdin
Standard input is empty
stdout
24/04