Java examples for java.time:LocalDateTime
LocalDateTime yesterday as String
//package com.java2s; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; public class Main { public static String yesterday(LocalDateTime now) { DateTimeFormatter formatter = DateTimeFormatter .ofPattern("yyyy-MM-dd"); return now.minus(1, ChronoUnit.DAYS).withHour(0).withMinute(0) .withSecond(0).format(formatter); }/*from w ww .ja v a 2 s .c om*/ }