I am trying to get my current system date and am formatting it into Etc/UTC and then into this "dd.MM.yyyy HH:mm z" format. The problem is this that the format function after formatting the date returns a string instead of date. Here is the code spinet below
final Date currentDate = new Date();
final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy HH:mm z");
dateFormatter.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
String finalDateTime= dateFormatter.format(currentDate);
System.out.println(finalDateTime);
Is there any alternative solution which allows me to format the date by keeping me within this date object because I have researched every date library after java 8 and before java 8, it seems like if I want to format any type of date or dateTime, I have to use a formatter which converts the given date into string.
Any Alternative solutions or it is not possible?