Example usage for org.joda.time DateTime now

List of usage examples for org.joda.time DateTime now

Introduction

In this page you can find the example usage for org.joda.time DateTime now.

Prototype

public static DateTime now() 

Source Link

Document

Obtains a DateTime set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:cn.cuizuoli.appranking.service.AppRankingService.java

License:Apache License

/**
 * deleteAppRankingHour//from w  w w.j a  v a2 s  . c  o  m
 */
@Transactional
public void deleteAppRankingHour() {
    String dateHour = DateTime.now().minusWeeks(1).toString("yyyyMMddHH");
    appRankingRepository.delete(dateHour);
    appRankingRepository.optimize();
}

From source file:cn.cuizuoli.appranking.task.AppRankingTask.java

License:Apache License

@Scheduled(cron = "0 0 * * * *")
public void execute() {
    JobParameters jobParameters = jobParametersBuilder.addString("DATE", DateUtil.toHour(DateTime.now()))
            .toJobParameters();/*from   ww w .j  a v a  2s  .  c o  m*/
    try {
        Job job = jobRegistry.getJob("appRankingJob");
        jobLauncher.run(job, jobParameters);
    } catch (NoSuchJobException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (JobExecutionAlreadyRunningException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (JobRestartException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (JobInstanceAlreadyCompleteException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    } catch (JobParametersInvalidException e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
    }
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_JUMPSTATE_START} event with a
 * {@link StateEventBody} payload.// w w w.j  a v a 2  s  .co  m
 *
 * @param state the target state for the jumpstate operation that we're raising the event for.
 * @return an Event instance for the JumpStateStart event.
 * @since 4.0
 */
public static Event jumpStateStart(State state) {
    if (state == null)
        throw new ArgumentNullException("state");

    return Events.toStateEvent(Events.EVENT_URI_JUMPSTATE_START, DateTime.now(), state);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events##EVENT_URI_JUMPSTATE_COMPLETE} event with a
 * {@link StateEventBody} payload./*from w  ww  .ja v a  2s  .c  o m*/
 *
 * @param state the target state for the jumpstate operation that we're raising the event for.
 * @return an Event instance for the JumpStateComplete event.
 * @since 4.0
 */
public static Event jumpStateComplete(State state) {
    if (state == null)
        throw new ArgumentNullException("state");

    return Events.toStateEvent(Events.EVENT_URI_JUMPSTATE_COMPLETE, DateTime.now(), state);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_ASSERTION_START} event with a
 * {@link AssertionEventBody} payload./*from   ww  w .j ava2  s .  c  om*/
 *
 * @param state     the {@link State} that is being asserted.
 * @param assertion the specific {@link Assertion} that is being applied.
 * @return an Event instance for the AssertionStart event.
 * @since 4.0
 */
public static Event assertionStart(State state, Assertion assertion) {
    if (state == null)
        throw new ArgumentNullException("state");
    if (assertion == null)
        throw new ArgumentNullException("assertion");

    return Events.toAssertionEvent(Events.EVENT_URI_ASSERTION_START, DateTime.now(), state, assertion);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_ASSERTION_COMPLETE} event with a
 * {@link AssertionEventBody} payload.//from w w w . java2 s.  co  m
 *
 * @param state     the {@link State} that is being asserted.
 * @param assertion the specific {@link Assertion} that is being applied.
 * @return an Event instance for the AssertionStart event.
 * @since 4.0
 */
public static Event assertionComplete(State state, Assertion assertion) {
    if (state == null)
        throw new ArgumentNullException("state");
    if (assertion == null)
        throw new ArgumentNullException("assertion");

    return Events.toAssertionEvent(Events.EVENT_URI_ASSERTION_COMPLETE, DateTime.now(), state, assertion);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_ASSSERTION_FAILED} with a
 * {@link AssertionWithMessageEventBody} payload.
 *
 * @param state     the {@link State} that is being asserted.
 * @param assertion the specific {@link Assertion} that is being applied.
 * @param message   the failure message to be included in teh event
 * @return an Event instance for the AssertionFailed event.
 * @since 4.0/* w ww.  j ava2 s  .c  o m*/
 */
public static Event assertionFailed(State state, Assertion assertion, String message) {
    if (state == null)
        throw new ArgumentNullException("state");
    if (assertion == null)
        throw new ArgumentNullException("assertion");
    if (message == null)
        throw new ArgumentNullException("message");

    return new Event(Events.EVENT_URI_ASSSERTION_FAILED, DateTime.now(),
            new AssertionWithMessageEventBody(state.getStateId(), assertion.getAssertionId(), message));
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_MIGRATION_START} event with a
 * {@link MigrationEventBody} payload./*from   ww w  .j a  v  a  2  s.co  m*/
 *
 * @param migration the {@link Migration} being performed.
 * @return an Event instance for the MigrationStart event.
 * @since 4.0
 */
public static Event migrationStart(Migration migration, State fromState, State toState) {
    if (migration == null)
        throw new ArgumentNullException("migration");

    return Events.toMigrationEvent(Events.EVENT_URI_MIGRATION_START, DateTime.now(), migration, fromState,
            toState);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_MIGRATION_COMPLETE} event with a
 * {@link MigrationEventBody} payload./* ww w . ja  v a2 s .  co  m*/
 *
 * @param migration the {@link Migration} being performed.
 * @return an Event instance for the MigrationComplete event.
 * @since 4.0
 */
public static Event migrationComplete(Migration migration, State fromState, State toState) {
    if (migration == null)
        throw new ArgumentNullException("migration");

    return Events.toMigrationEvent(Events.EVENT_URI_MIGRATION_COMPLETE, DateTime.now(), migration, fromState,
            toState);
}

From source file:co.mv.wb.event.Events.java

License:Open Source License

/**
 * Builds an {@link Event} instance for the {@link Events#EVENT_URI_MIGRATION_FAILED} event with a
 * {@link MigrationWithMessageEventBody} payload.
 *
 * @param migration the {@link Migration} being performed.
 * @param message   the message giving more detail about why the migration failed.
 * @return 4.0//w  w  w. j  a v a  2  s  . co m
 */
public static Event migrationFailed(Migration migration, State fromState, State toState, String message) {
    if (migration == null)
        throw new ArgumentNullException("migration");
    if (message == null)
        throw new ArgumentNullException("message");

    UUID fromStateId = fromState == null ? null : fromState.getStateId();
    String fromStateName = fromState == null ? null : fromState.getName().orElse(null);

    UUID toStateId = toState == null ? null : toState.getStateId();
    String toStateName = toState == null ? null : toState.getName().orElse(null);

    return new Event(Events.EVENT_URI_MIGRATION_FAILED, DateTime.now(), new MigrationWithMessageEventBody(
            migration.getMigrationId(), fromStateId, fromStateName, toStateId, toStateName, message));
}