New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert PersianDate to Calendar format #1

Closed
ShahabShahab opened this Issue May 27, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@ShahabShahab

ShahabShahab commented May 27, 2017

Hello mr.Mir rajabi

How can I convert a simple persiandate to a calendar type object?
I am trying this code, but this always returns me the current time in millis!
PersianDate persianDate1 = new PersianDate(1396,3 ,22);
System.out.println(persianDate1.getTime());
Date date = DateConverter.persianToCivil(persianDate1);
Calendar calendar1 = Calendar.getInstance();
calendar.setTime(date);
System.out.println(calendar.getTimeInMillis());

@mirrajabi

This comment has been minimized.

Show comment
Hide comment
@mirrajabi

mirrajabi May 27, 2017

Member

Hi.
This might be what you're looking for

PersianDate persianDate = new PersianDate(1396,3 ,22);
CivilDate civilDate = DateConverter.persianToCivil(persianDate);
Calendar calendar = (Calendar)Calendar.getInstance().clone();
calendar.set(civilDate.getYear(), civilDate.getMonth()-1, civilDate.getDayOfMonth());
System.out.println(calendar.getTime());
Member

mirrajabi commented May 27, 2017

Hi.
This might be what you're looking for

PersianDate persianDate = new PersianDate(1396,3 ,22);
CivilDate civilDate = DateConverter.persianToCivil(persianDate);
Calendar calendar = (Calendar)Calendar.getInstance().clone();
calendar.set(civilDate.getYear(), civilDate.getMonth()-1, civilDate.getDayOfMonth());
System.out.println(calendar.getTime());

@mirrajabi mirrajabi added the question label May 27, 2017

@mirrajabi mirrajabi changed the title from Change PersianDate to a CalendarFormat to Convert PersianDate to Calendar format May 27, 2017

@mirrajabi mirrajabi closed this May 27, 2017

@ShahabShahab

This comment has been minimized.

Show comment
Hide comment
@ShahabShahab

ShahabShahab May 28, 2017

Yes exactly!

I got to this solution yesterday eventually.

Thanks for your time

ShahabShahab commented May 28, 2017

Yes exactly!

I got to this solution yesterday eventually.

Thanks for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment