我有这个型号:
public class Event {
private String name;
private Date start;
private Date end;
}
Run Code Online (Sandbox Code Playgroud)
和存储库为
@Repository
public interface EventRepository extends JpaRepository<Event, Long> {
List<Event> findByEventTypeAccount(Account account);
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是,我将传递一个日期,需要检查日期间start和endEG(我将通过9月30日期和需要找到具有9月30日他们之间的所有条目start和end)
有点像findDateisBetweenStartAndEnd(Date date)?
我班上有以下代码
private static final SimpleDateFormat SDF_ISO_DATE = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat SDF_ISO_TIME = new SimpleDateFormat("HH:mm:ss");
public static String getTimeStampAsString(final long time) {
TimeZone tz = TimeZone.getTimeZone("UTC");
SDF_ISO_DATE.setTimeZone(tz);
SDF_ISO_TIME.setTimeZone(tz);
return SDF_ISO_DATE.format(
new Date(time)) + " " + SDF_ISO_TIME.format(new Date(time)
);
}
Run Code Online (Sandbox Code Playgroud)
在我的多线程应用程序中,以下方法将来会返回日期,即使对于当前日期,静态方法或变量是否对此负责?
编辑:
我有以下代码来重现和证明答案中提到的内容,但仍然无法.可以帮助我同样的一些人.
public static void main(String[] args) throws InterruptedException, ExecutionException {
Callable<String> task = new Callable<String>(){
public String call() throws Exception {
return DateUtil.getTimeStampAsString(1524567870569L);
}
};
//pool with 50 threads
ExecutorService exec = Executors.newFixedThreadPool(50);
List<Future<String>> results = …Run Code Online (Sandbox Code Playgroud) 我有以下对象
{
"timetable": {
"MONDAY": {
"start-end0": {},
"start-end1": {},
"start-end2": {},
"start-end3": {},
"start-end4": {}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要添加"start-end5"到MONDAY.我试图使用点运算符星期一,就像timetable.monday.start-end5={}它说周一未定义