Hi in the below code want to remove T and Zone from the LocalDateTime .
Can any one help me with this issue.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
LocalDateTime time = LocalDateTime.now();
firstDayOfQuarteropp = time.with(time.getMonth().firstMonthOfQuarter())
.with(TemporalAdjusters.firstDayOfMonth());
Log.d("firstDayOfQuarteropp", String.valueOf(firstDayOfQuarteropp));
lastDayOfQuarteropp = firstDayOfQuarteropp.plusMonths(2)
.with(TemporalAdjusters.lastDayOfMonth());
Log.d("lastDayOfQuarteropp", String.valueOf(lastDayOfQuarteropp));
}
Actual output:
2020-04-01T11:54:05.514
Expected output:
2020-04-01 11:54:05
You need to use DateTimeFormatter along with LocalDateTime
LocalDateTime time = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formatDateTime = time.format(formatter);
Log.d("FormattedTime", "Time: " + formatDateTime);