Convert Gregorian date to Hijri date In LINQ sql
Thank you so much
I have solved the problem
This code is for anyone who wants to use it
public static Service_Get_Data Get_Data_D(string svrIDE)
{
Exam_Entity _db = new Exam_Entity();
CultureInfo arSA = new CultureInfo("ar-SA");
arSA.DateTimeFormat.Calendar = new HijriCalendar();
return ((from m in _db.Svr_M
join d in _db.Svr_D
on m.svrIDE equals d.svrIDE
join b in _db.sch_trans on
d.TRN_recIdNew equals b.rec_id
join s in _db.Saf_List on
b.saf_id equals s.saf_id
join u in _db.Sub_List on
b.sub_id equals u.sub_id
join E in _db.encodingMSG on
d.svrNoteID equals E.EncToId
join O in _db.Office on
b.org_id equals O.OfficeID
where d.svrIDE == svrIDE && s.saf_id == u.saf_id && E.EncId == 4001
select new
{
sch_trans = b,
svr_M = m,
svr_D = d,
saf = s,
sub = u,
encodingMSG = E,
Office = O,
H_DateOfBirth = m.DateOfBirth.ToString(),
}
).AsEnumerable().Select(x => new Service_Get_Data
{
sch_trans = x.sch_trans,
svr_M = x.svr_M,
svr_D = x.svr_D,
saf = x.saf,
sub = x.sub,
encodingMSG = x.encodingMSG,
Office = x.Office,
H_DateOfBirth = Convert.ToDateTime(x.H_DateOfBirth).ToString("yyyy-MM-dd", arSA)
}).FirstOrDefault());
}
How can i convert Gregorain year to Hijri year?
You can simply pass a TemporalAccessor
e.g. LocalDate
, ZonedDateTime
etc. to HijrahChronology.INSTANCE#date
as shown below:
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.time.chrono.HijrahChronology;
import java.time.chrono.HijrahDate;
import java.time.temporal.TemporalAdjusters;
public class Main {
public static void main(String[] args) {
// Change the time-zone as per your requirement.
ZoneId myZoneId = ZoneId.of("Etc/UTC");
HijrahDate hijrahDate1 = HijrahChronology.INSTANCE.date(LocalDate.now(myZoneId));
System.out.println(hijrahDate1);
// ########Another example########
// HijrahDate on the last day of January 1994 at the time zone of Etc/UTC
HijrahDate hijrahDate2 = HijrahChronology
.INSTANCE // Instance of HijrahChronology
.date(LocalDate.of(1994, Month.JANUARY, 1) // LocalDate of 01-Jan-1994
.with(TemporalAdjusters.lastDayOfMonth()) // On the last day of Jan-1994
.atStartOfDay() // At the start of the day i.e. 00:00
.atZone(myZoneId)); // At the time zone of Etc/UTC
System.out.println(hijrahDate2);
}
}
Output:
Hijrah-umalqura AH 1441-12-27
Hijrah-umalqura AH 1414-08-19
Learn more about the Java-8 date-time API at Trail: Date Time.
Convert gregorian date to Hijri date
Yeartext1 , Monthtext1 and Monthtext1 are UITextField
resultlable is UILabel
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
let GregorianDate = dateFormatter.dateFromString("\(Daytext1.text!)-\(Monthtext1.text!)-\(Yeartext1.text!)")
let islamic = NSCalendar(identifier: NSCalendarIdentifierIslamicUmmAlQura)
let components = islamic?.components(NSCalendarUnit(rawValue: UInt.max), fromDate: GregorianDate!)
resultlable.text = "\(components!.year) - \(components!.month) - \(components!.day)"
It will take an Gregorian Date 5-10-2015 and it will give you the islamic date 1436 - 12 - 22
*There is a small probability of one day error
you can check this converter
http://www.islamicfinder.org/Hcal/hdate_next.php
How to convert a Gregorian date to an Islamic (Hijri) date?
Finally I found the solution here in this new library .
Related Topics
Creating Decoration View as Custom Column in UIcollection View
Issue with Optional Core Data Relationship Using Nspersistentcloudkitcontainer
Bleed Through from Nsbutton Checkbox on Non-Transparent Nspopover
Decrypting Des with Commoncrypto in Swift 3
How to Get Alphabetic Tableview Sections from an Object
How to Show Two Row of Text in a Menu Bar App in MAC Os
Can't Hide Status Bar in Avplayerviewcontroller's Portrait Mode
Realm Data Insertion Took Over 7Mins for Big Size JSON
How Pass Data from Button in Tableviewcell to View Controller
Swift-Making an Sknode Simply "Move Forward" on an Angle
Use Tableviewcontroller Inside Skscene
Thread Safety of Method Calls on "Shared" Static Constant Property
Uislider Handle Changes Width on Different Size Ipads