Search code examples
javaandroidcalendarunix-timestamphijri

Use UNIXTIMESTAMP with ummalqura-calendar Library


I am using ummalqura-calendar to Show Hijri Date in my Android Application

am getting date from back end Service as UNIXTIMESTAMP, How can i use this format with the library


Solution

  • If you have a unix time stamp (seconds since epoch), you should be able to just multiply the timestamp by 1000 to get milliseconds and use setTime;

    Calendar uCal = new UmmalquraCalendar();
    uCal.setTime(new Date(myTimestamp * 1000));
    

    If you already have the timestamp in milliseconds, just leave out the multiplication.