1

When I try to parse Date object which has a format like 1950-01-01T00:00:00 then date time get it as yesterday.

i also tried to get time zone with DateTimeZone.getDefault() but its still not working. Which timezone can I use to fix it?

DateTime dateTime = new DateTime(1950-01-01T00:00:00, DateTimeZone.UTC);

output:
dateTime.getDayOfMonth() = 31
dateTime.getMonthOfYear() = 12
dateTime.getYear() = 1949

Can you please help me?

Thanks.

1 Answer 1

1

fixed with adding below code in application class

DateTimeZone.setDefault(DateTimeZone.forID("Europe/Istanbul"));

Sign up to request clarification or add additional context in comments.

2 Comments

DateTime dateTime = new DateTime(1950-01-01T00:00:00, DateTimeZone.forID("Europe/Istanbul")); would be better in order to avoid manipulating the default time zone (maybe the user on the mobile phone wants another one per standard, or other apps or other parts of the app shall not suffer from such a change).
@Meno thats local app :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.