fork download
  1. /* package whatever; // don't place package name! */
  2. import java.text.SimpleDateFormat;
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Calendar calendar = Calendar.getInstance();
  13.  
  14. TimeZone timeZone = TimeZone.getTimeZone("Europe/Istanbul");
  15.  
  16. calendar.setTimeZone(timeZone);
  17.  
  18. System.out.println(timeZone.inDaylightTime(new Date()));
  19. if (timeZone.inDaylightTime(new Date())){
  20. calendar.add(Calendar.MILLISECOND, timeZone.getDSTSavings());
  21. }
  22.  
  23.  
  24.  
  25. SimpleDateFormat simpleDateFormatLocal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  26. simpleDateFormatLocal.setTimeZone(TimeZone.getTimeZone("Europe/Istanbul"));
  27.  
  28. System.out.println("Current date and time : " + simpleDateFormatLocal.format(calendar.getTime()));
  29. System.out.println("The TimeZone is : " + calendar.getTimeZone().getID());
  30.  
  31. }
  32. }
Success #stdin #stdout 0.14s 321280KB
stdin
Standard input is empty
stdout
false
Current date and time : 2015-11-01 20:08:56
The TimeZone is : Europe/Istanbul