fork download
  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;
  3. import java.util.TimeZone;
  4.  
  5. public class Main {
  6. public static void main(String[] argv) throws Exception {
  7. SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
  8. String asGmt = df.format(new Date()) + " GMT";
  9. //System.out.println(asGmt);
  10. System.out.println(toDatabaseDate(new Date()));
  11. System.out.println(TimeZone.getDefault());
  12. }
  13.  
  14. public static Date toDatabaseDate(Date value)
  15. {
  16. Date obfuscated = null;
  17. if (value!=null)
  18. {
  19. TimeZone tz = TimeZone.getDefault();
  20. long faketime = value.getTime();
  21. long offset1 = tz.getOffset(faketime);
  22. //long offset2 = tz.getOffset(faketime - offset1);
  23. obfuscated = new Date(faketime - offset1);
  24. }
  25. return obfuscated;
  26. }
  27. }
Success #stdin #stdout 0.17s 321472KB
stdin
Standard input is empty
stdout
Mon Aug 03 06:50:23 GMT 2015
sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]