My system time differs from what java's new Date() tells (+ 4 hours),
so I think it's because some java settings.
How can I make java time to be always as my linux system time?
(by editing some configuration file)
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
http://minaret.biz/tips/timezone.html
I am not sure but it might be helpful.
use
System.getCurrentTimeInMillis();
and then take a calendar instance and set Your time..
If you want to change the time zone programmatically then you can use:
I prefer this method because it doesn't rely on people remembering to run my code with the correct time zone arguments.
This code helped me.
You can use
TimeZone.setDefault(..)
when your application starts, or pass the timezone as command-line argument:-Duser.timezone=GMT
Is this code printing the right date/time? Else, there's some other problem.