class="java" name="code"> public static void main(String[] args) { String result = ""; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String now = formatter.format(new Date()); String hour = now.split(" ")[1].toString().split(":")[0]; if (Integer.parseInt(hour) < 12) { Calendar todayEnd = Calendar.getInstance(); todayEnd.set(Calendar.HOUR_OF_DAY, 23); todayEnd.set(Calendar.MINUTE, 59); todayEnd.set(Calendar.SECOND, 59); result = formatter.format(todayEnd.getTime()); System.out.println(result); } else { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); result = formatter.format(calendar.getTime()); } }