BALRAM AWASTHI

BALRAM AWASTHI

  • NA
  • 225
  • 13.3k

How to convert indian date time into german date time

Jul 14 2015 1:12 AM
Hi,
 
My pbroblem is that My application calls a web service and web service is connect with database.
 
service is running in server(which is configured with german date time) and enter the date time in database of germany but I am currently working on nunit
cases it passes indian date time.
 
Basically My issue is that how to convert indian date time into german date time. 
 
Thanks,
Balram 

Answers (2)

0
Upendra Pratap Shahi

Upendra Pratap Shahi

  • 182
  • 10.4k
  • 2.1m
Jul 14 2015 2:59 AM

var germanCultureInfo = CultureInfo.CreateSpecificCulture("de-DE");

DateTime issue = DateTime.ParseExact(date, "dd/MM/yyyy", germanCultureInfo);

0
Rajeev Punhani

Rajeev Punhani

  • 355
  • 4.7k
  • 1.6m
Jul 14 2015 2:51 AM
Please use  DateTime.ParseExact for converting
 
DateTime issue = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); 
where date is the date string you are passing  and second parameter is format of string supplied,third parameter is culture.If you use CultureInfo.InvariantCulture then default culture of Webserver will be taken In your case its german so use
var germanCultureInfo = CultureInfo.CreateSpecificCulture("de-DE");
DateTime issue = DateTime.ParseExact(date, "dd/MM/yyyy", germanCultureInfo);