Avatar of satmisha
satmisha
Flag for India asked on

convert C# code to java

Hi Team,

I am newbie here and stuck on quite small problem where there is a requirement to convert c# code to the java code.
This c# code works fine but I need to use this is java where it doesn't work. Please help

TimeSpan time = new TimeSpan(2, 0, 0, 0);
TimeSpan endtime = new TimeSpan(2, 3, 0, 0);
string start_date = DateTime.Now.Add(time).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
String end_date = DateTime.Now.Add(endtime).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
String payload = "{\"end_date\": \""+end_date+"\",\"start_date\": \""+start_date+"\"}";

Looking forward to hearing from you experts.

Satmisha
JavaC#

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
CEHJ

What is the Java context please?
Ares Kurklu

There is no TimeSpan in java you may have to use something like java.time.Period
ASKER CERTIFIED SOLUTION
awking00

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
satmisha

ASKER
Apologies for late reply.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
CEHJ

You got the code converted?