Example usage for org.joda.time MutableDateTime toString

List of usage examples for org.joda.time MutableDateTime toString

Introduction

In this page you can find the example usage for org.joda.time MutableDateTime toString.

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).

Usage

From source file:Bootstrap.java

License:Open Source License

public void doJob() {
    if (Play.mode == Play.Mode.DEV) {

        //BigTable.deleteAll();
        // BigTableR.deleteAll();
        ////from   w w  w . j  av a2s  .  c om
        Invoice.deleteAll();
        Customer.deleteAll();
        Employee.deleteAll();
        User.deleteAll();

        Fixtures.load("test-datas.yml");

        int maxEntries = 2500;
        int maxEntriesR = 500;

        if (BigTable.count() == 0) {
            Logger.info("Creating " + maxEntries + " entries for testing");

            BigTable bigTable;
            // Create an enty in the past, so that AsyncBlotter can fetch the updated rows
            MutableDateTime aDate = new MutableDateTime();
            aDate.setMonthOfYear(1);
            aDate.setYear(2010);

            for (int i = 0; i < maxEntries; i++) {
                bigTable = new BigTable();
                bigTable.variable01 = Math.random() * 100;
                bigTable.variable02 = Math.random() * 100;
                bigTable.lastUpdated = aDate.toDate();
                if (i % 100 == 0) {
                    aDate.addDays(1);
                    Logger.info("Created " + i + " entries" + aDate.toString());
                }
                bigTable.save();
            }
        }
        if (BigTableR.count() == 0) {
            Logger.info("Creating " + maxEntriesR + " entries for BigTableR");

            BigTableR bigTableR;

            int j = 0;
            String locCurs = "Localisation #0";
            String segCurs = "Segment #0";
            String perCurs = "Period #0";

            for (int i = 0; i < maxEntriesR; i++) {
                bigTableR = new BigTableR();
                bigTableR.difference = Math.random();
                bigTableR.evolution = Math.random() * 10;
                bigTableR.localisation = locCurs;
                bigTableR.segment = segCurs;
                bigTableR.period = perCurs;
                bigTableR.indicator = new StringBuffer("Indicator #").append(i).toString();
                bigTableR.product = new Long(10 * i);
                if (i % 100 == 0) {
                    Logger.info("Created " + i + " entries");
                    locCurs = new StringBuffer("Localisation ").append(j).toString();
                    segCurs = new StringBuffer("Segment #").append(j).toString();
                    perCurs = new StringBuffer("Period #").append(j).toString();
                    j++;
                }
                bigTableR.save();
            }

        }
    }
}

From source file:org.n52.sos.cache.quartz.QuartzCacheScheduler.java

License:Apache License

public QuartzCacheScheduler(AccessGDB geoDB, boolean updateCacheOnStartup, LocalTime cacheUpdateTime) {
    super(geoDB, updateCacheOnStartup, cacheUpdateTime);

    try {//from w  w w  .j a v  a 2 s  . c  o  m
        this.quartz = new StdSchedulerFactory().getScheduler();
        this.quartzFactory = new LocalJobFactory();
        this.quartz.setJobFactory(this.quartzFactory);
        this.quartz.start();
    } catch (SchedulerException e) {
        LOGGER.warn("Could not initialize cache scheduling", e);
        return;
    }

    if (!updateCacheOnStartup) {
        LOGGER.info("Update cache on startup disabled!");
    } else {
        try {
            schedule(new UpdateCacheTask(getCandidates()), 0);
            //            List<AbstractEntityCache<?>> requiresUpdates = cacheUpdateRequired();
            //            if (!requiresUpdates.isEmpty()) {
            //               LOGGER.info(String.format("Cache update required for: %s", requiresUpdates.toString()));
            //               /*
            //                * now
            //                */
            //               schedule(new UpdateCacheTask(requiresUpdates), 0);   
            //            }
            //            else {
            //               LOGGER.info("No cache update required. Last update not longer ago than minutes "+FIFTEEN_MINS_MS/(1000*60));
            //            }
        } catch (SchedulerException e) {
            LOGGER.warn(e.getMessage(), e);
            LOGGER.warn("could not initialize cache. disabling scheduled updates.");
            return;
        }
    }

    MutableDateTime mdt = resolveNextScheduleDate(this.getCacheUpdateTime(), new DateTime());
    DateTime now = new DateTime();

    try {
        //         schedule(new UpdateCacheTask(getCandidates()), ONE_HOUR_MS,
        //               ONE_HOUR_MS);
        schedule(new UpdateCacheTask(getCandidates()), mdt.getMillis() - now.getMillis(), ONE_HOUR_MS * 24);
    } catch (SchedulerException e) {
        LOGGER.warn(e.getMessage(), e);
    }

    LOGGER.severe("Next scheduled cache update: " + mdt.toString());

    /*
     * start ONE monitoring after 1 minute and check if the .lock file
     * is older than 30 minutes -> an artifact .lock file!!
     */
    try {
        schedule(new MonitorCacheTask(ONE_HOUR_MS / 2), ONE_HOUR_MS / 60);
    } catch (SchedulerException e) {
        LOGGER.warn(e.getMessage(), e);
    }
}

From source file:org.n52.sos.cache.TimerTaskCacheScheduler.java

License:Apache License

private TimerTaskCacheScheduler(AccessGDB geoDB, boolean updateCacheOnStartup, LocalTime lt) {
    super(geoDB, updateCacheOnStartup, lt);

    this.cacheTimer = new Timer(true);
    this.monitorTimer = new Timer(true);

    if (!updateCacheOnStartup) {
        LOGGER.info("Update cache on startup disabled!");
    } else {//w ww.  j a v  a 2  s . co m
        try {
            List<AbstractEntityCache<?>> requiresUpdates = cacheUpdateRequired();
            if (!requiresUpdates.isEmpty()) {
                LOGGER.info(String.format("Cache update required for: %s", requiresUpdates.toString()));
                /*
                 * now
                 */
                this.cacheTimer.schedule(new UpdateCacheTask(requiresUpdates), 0);
            } else {
                LOGGER.info("No cache update required. Last update not longer ago than minutes "
                        + FIFTEEN_MINS_MS / (1000 * 60));
            }
        } catch (FileNotFoundException e) {
            LOGGER.warn(e.getMessage(), e);
            LOGGER.warn("could not initialize cache. disabling scheduled updates.");
            return;
        }
    }

    MutableDateTime mdt = resolveNextScheduleDate(lt, new DateTime());

    this.cacheTimer.scheduleAtFixedRate(new UpdateCacheTask(getCandidates()), mdt.toDate(), ONE_HOUR_MS * 24);

    //      Calendar c = new GregorianCalendar();
    //      c.add(Calendar.MINUTE, 5);
    //      
    //      this.cacheTimer.scheduleAtFixedRate(new UpdateCacheTask(candidates), c.getTime(), ONE_HOUR_MS/2);

    LOGGER.severe("Next scheduled cache update: " + mdt.toString());

    /*
     * start ONE monitoring after 30 minutes and check if the .lock file
     * is older than 30 minutes -> an artifact .lock file!!
     */
    this.monitorTimer.schedule(new MonitorCacheTask(ONE_HOUR_MS / 2), ONE_HOUR_MS / 60);
}