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
satmishaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
What is the Java context please?
0
Ares KurkluSoftware EngineerCommented:
There is no TimeSpan in java you may have to use something like java.time.Period
0
awking00Commented:
Showing the C# code does not really help, since there is no way of directly converting C# objects to Java objects. You need to tell the Java experts precisely what the C# code is doing. For example, what does it mean to be a TimeSpan constructed with 4 int type parameters? What part does the use of a TimeSpan and the CultureInfo.InvariantCulture play in the creation and formatting of the start and end date strings? What would a sample payload string look like with sample formatted begin and end dates after any escape characters
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
satmishaAuthor Commented:
Apologies for late reply.
0
CEHJCommented:
You got the code converted?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.