sahaab / HijriCalendar-master

A Hijri (Islamic) Calendar Library
Other
26 stars 20 forks source link

How can I toast the Hijri date #1

Closed freebumba27 closed 9 years ago

freebumba27 commented 9 years ago

On clicking on the date it's showing the Georgian Calendar date. I want to show Hijri date. How to do that?

sahaab commented 9 years ago

please use this function HijriCalendarDate.getSimpleDate(Calendar.getInstance(),"0") to get the hijri date for that calendar Date instance

freebumba27 commented 9 years ago

@Override
public void onSelectDate(Date date, View view) {
Toast.makeText(getApplicationContext(), HijriCalendarDate.getSimpleDate(Calendar.getInstance(), 0), Toast.LENGTH_SHORT).show();
}

I am trying this but it's always giving today's Hijri date as toast. How can I get selected Hijri Date

sahaab commented 9 years ago

Please wait a moment, i will construct the code for you and send you it

Assalamu Alaikum, Sahaab Zahid On Jul 14, 2015 1:57 AM, "Bumba" notifications@github.com wrote:

@Overridepublic void onSelectDate(Date date, View view) {Toast.makeText(getApplicationContext(), HijriCalendarDate.getSimpleDate(Calendar.getInstance(), 0), Toast.LENGTH_SHORT).show(); }

I am trying this but it's always giving current Hijri date as toast. How can I get selected Hijri Date

— Reply to this email directly or view it on GitHub https://github.com/sahaab/HijriCalendar-master/issues/1#issuecomment-121139129 .

freebumba27 commented 9 years ago

That will be really helpful.

sahaab commented 9 years ago
public static Calendar DateToCalendar(Date date){ 
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);
  return cal;
}

@Override
public void onSelectDate(Date date, View view) {
    Toast.makeText(getApplicationContext(),
         HijriCalendarDate.getSimpleDate(DateToCalendar(date), 0),
         Toast.LENGTH_SHORT).show();
}
freebumba27 commented 9 years ago

Work like charm.. Thanks I have modified little bid, It looks like this -

@Override
public void onSelectDate(Date date, View view) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    Toast.makeText(getApplicationContext(), HijriCalendarDate.getSimpleDate(cal, 0), Toast.LENGTH_SHORT).show();
}
sahaab commented 9 years ago

No problem :D , glad to help and yep that is fine, if you like, you may email me your app when you are done, I would love to see it inshaAllah :D

freebumba27 commented 9 years ago

It have modified couple of things It's look like this. screenshot_2015-07-14-12-02-22