Skip to content

Instantly share code, notes, and snippets.

View haiphucnguyen's full-sized avatar
🎯
Focusing

Hai Phuc Nguyen haiphucnguyen

🎯
Focusing
View GitHub Profile
@SpringBootApplication
public class QuartzDemoApplication {
public static void main(String[] args) {
SpringApplication.run(QuartzDemoApplication.class, args);
}
}
@Bean
public Trigger scheduleTrigger() {
return newTrigger().withIdentity("trigger").forJob(scheduleJob()).
withSchedule(CronScheduleBuilder.cronSchedule("0 * * * * ?")).build();
}
@Bean
public JobDetail scheduleJob() {
return JobBuilder.newJob(ScheduleTask.class).storeDurably()
.withIdentity("sample_schedule").withDescription("Sample schedule task").build();
}
@Component
public class ScheduleTask extends QuartzJobBean {
private static final Logger LOG = LoggerFactory.getLogger(ScheduleTask.class);
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
LOG.info("The current time is: " + dateFormat.format(new Date()));
}
package com.mycollab.billing.fastspring
import com.fasterxml.jackson.annotation.{JsonCreator, JsonProperty}
import com.fasterxml.jackson.core.{JsonGenerator, JsonParser}
import com.fasterxml.jackson.databind._
import com.fasterxml.jackson.databind.annotation.{JsonDeserialize, JsonSerialize}
import com.fasterxml.jackson.databind.module.SimpleModule
import org.joda.time.LocalDateTime
import org.joda.time.format.DateTimeFormat