2023-03-30 00:00:00.0(Timestamp), 2023-03-30 00:00:00.0(Timestamp) 怎么设置成2023-03-30:23:59:59
时间: 2024-05-06 14:03:21 浏览: 76
可以使用以下代码将时间戳的时间设置为23:59:59:
```
import java.sql.Timestamp;
import java.util.Calendar;
Timestamp timestamp1 = Timestamp.valueOf("2023-03-30 00:00:00.0");
Timestamp timestamp2 = Timestamp.valueOf("2023-03-30 00:00:00.0");
Calendar cal = Calendar.getInstance();
cal.setTime(timestamp1);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
timestamp1 = new Timestamp(cal.getTimeInMillis());
cal.setTime(timestamp2);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
timestamp2 = new Timestamp(cal.getTimeInMillis());
System.out.println(timestamp1);
System.out.println(timestamp2);
```
输出结果:
```
2023-03-30 23:59:59.0
2023-03-30 23:59:59.0
```
阅读全文