How to return two different time formats? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to return two different time formats?

I'm trying to create a method to return US time format and a Uk time format in one method. public class DateFormatter { public String formatDate(Date date) { if(date == null) { throw new IllegalArgumentException(); } String formatDate = date.getMonth() + "/" + date.getDay() + "/" + date.getYear(); return formatDate; } }

4th Oct 2019, 10:22 PM
Lame Lame
Lame Lame - avatar
1 Answer
+ 1
In Java there is a thing known as ZoneDateTime you can use that.
4th Oct 2019, 10:47 PM
A͢J
A͢J - avatar