0
Error with java.time??
I wrote a program that uses java.time It works just fine save for the method to get the current hour. e.g. it returned 21 when it should be 13 or 2 when it should be 18 https://code.sololearn.com/cS2lKCYqU29W/?ref=app
4 odpowiedzi
+ 4
Not sure but I guess it probably returns the server time on which it's running.
+ 2
I have changed your code a little using zoneid and it is working for me
https://code.sololearn.com/ca59WzX8nE7q/?ref=app
I hope this helps you
+ 2
for name of month there is API
import java.time.format.TextStyle;
import java.util.Locale;
/..
String monthName =
Month.of(month).getDisplayName(TextStyle.FULL, Locale.getDefault() );
+ 1
Only if you run it on your system, it will return the system date and time when you call the now().
On sololearn it's not the same.
Even if you use the ZoneId class then the output will give the correct date but your time will be the difference between time in your zone and the GMT. If you are ahead then it will result in + or if you are lagging then it will result in - time.