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:com.gst.spm.service.SpmService.java

License:Apache License

public Survey createSurvey(final Survey survey) {
    this.securityContext.authenticatedUser();

    final Survey previousSurvey = this.surveyRepository.findByKey(survey.getKey(), new Date());

    if (previousSurvey != null) {
        this.deactivateSurvey(previousSurvey.getId());
    }//from   ww  w .  j  a v  a 2  s.c  o m

    // set valid from to start of today
    final DateTime validFrom = DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0)
            .withMillisOfSecond(0);

    survey.setValidFrom(validFrom.toDate());

    // set valid from to end in 100 years
    final DateTime validTo = validFrom.withDayOfMonth(31).withMonthOfYear(12).withHourOfDay(23)
            .withMinuteOfHour(59).withSecondOfMinute(59).withMillisOfSecond(999).plusYears(100);

    survey.setValidTo(validTo.toDate());

    return this.surveyRepository.save(survey);
}

From source file:com.gst.spm.service.SpmService.java

License:Apache License

public void deactivateSurvey(final Long id) {
    this.securityContext.authenticatedUser();

    final Survey survey = this.surveyRepository.findOne(id);

    if (survey != null) {
        // set valid to to yesterday night
        final DateTime dateTime = DateTime.now().withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59)
                .withMillisOfSecond(999).minusDays(1);
        survey.setValidTo(dateTime.toDate());

        this.surveyRepository.save(survey);
    }//from  ww  w. j  a v a 2 s .  c o  m
}

From source file:com.gtp.tradeapp.entity.HistoricalPortfolio.java

License:Apache License

@PrePersist
protected void onCreate() {
    portfolioDate = DateTime.now();
}

From source file:com.heroku.demo.HomeController.java

License:Apache License

@RequestMapping(method = RequestMethod.GET)
public String home(ModelMap model) {
    //        List<Record> records = repository.findAll();
    //        model.addAttribute("records", records);
    //        model.addAttribute("insertRecord", new Record());
    return "home " + DateTime.now() + " " + UUID.randomUUID();
}

From source file:com.hp.autonomy.hod.redis.RedisTokenRepository.java

License:MIT License

private int getExpirySeconds(final DateTime dateTime) {
    return Seconds.secondsBetween(DateTime.now(), dateTime).getSeconds();
}

From source file:com.hp.autonomy.searchcomponents.idol.test.IdolTestUtils.java

License:MIT License

@Override
public QueryRestrictions<String> buildQueryRestrictions() {
    return new IdolQueryRestrictions.Builder().setQueryText("*").setFieldText("").setDatabases(getDatabases())
            .setMinDate(null).setMaxDate(DateTime.now()).setLanguageType(null).setAnyLanguage(true)
            .setStateMatchId(Collections.<String>emptyList())
            .setStateDontMatchId(Collections.<String>emptyList()).build();
}

From source file:com.ibm.common.activitystreams.util.Converters.java

License:Apache License

/**
 * Method tryParseDuration.//from w w w.  j a v  a2s  . c  om
 * @param input String
 * @return Duration
 */
private static Duration tryParseDuration(String input) {
    try {
        return Period.parse(input).toDurationFrom(DateTime.now());
    } catch (Throwable t) {
        return null;
    }
}