fork 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( "Demonstration of IdeOne.com refusing to localize. Apparently a non-standard JVM.") ;
  17.  
  18. Locale before = Locale.getDefault() ;
  19. Locale.setDefault( Locale.FRANCE ) ;
  20. Locale after = Locale.getDefault() ;
  21.  
  22. System.out.println( before) ;
  23. System.out.println( after ) ;
  24.  
  25. ZonedDateTime zdt = ZonedDateTime.now(
  26. ZoneId.of( "Pacific/Auckland" )
  27. );
  28.  
  29. // Use JVM’s current default `Locale`… but we get US English?
  30. DateTimeFormatter f =
  31. DateTimeFormatter.ofLocalizedDateTime( FormatStyle.LONG )
  32. //.withLocale( Locale.FRANCE )
  33. ;
  34. String output = zdt.format( f ) ;
  35. System.out.println( output ) ;
  36.  
  37. // Explicitly set Locale.FRANCE… but we still get US English?
  38. DateTimeFormatter f2 =
  39. DateTimeFormatter.ofLocalizedDateTime( FormatStyle.LONG )
  40. .withLocale( Locale.FRANCE )
  41. ;
  42. String output2 = zdt.format( f ) ;
  43. System.out.println( output2 ) ;
  44.  
  45. }
  46. }
Success #stdin #stdout 0.25s 36532KB
stdin
Standard input is empty
stdout
Demonstration of IdeOne.com refusing to localize. Apparently a non-standard JVM.
en_US
fr_FR
July 11, 2018 5:50:01 PM NZST
July 11, 2018 5:50:01 PM NZST