Example usage for org.joda.time DateTime DateTime

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

Introduction

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

Prototype

public DateTime() 

Source Link

Document

Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:DataRequestParser.java

private DateTime getDateWith(int year, int doy) {

    // temp date object
    DateTime dt = new DateTime();

    // set the year
    dt = dt.withYear(year);/*w ww.  j ava2s.  c om*/

    // set the day of year
    dt = dt.withDayOfYear(doy);

    return dt;

}

From source file:ListResources.java

License:Open Source License

/**
 * Returns start time for listTimeSeries.
 *
 * @return An hour ago - 5 minutes//from  www .j a  va 2 s  .  c om
 */
private static String getStartTime() {
    // Return an hour ago - 5 minutes
    DateTime dt = new DateTime().minusHours(1).minusMinutes(5);
    rfc3339.format(dt.toDate());
    return rfc3339.format(dt.toDate());
}

From source file:ListResources.java

License:Open Source License

/**
 * Returns end time for listTimeSeries./*from  w ww  .j  av a  2  s . co m*/
 *
 * @return An hour ago
 */
private static String getEndTime() {
    // Return an hour ago
    DateTime dt = new DateTime().minusHours(1);
    return rfc3339.format(dt.toDate());
}

From source file:CreateCustomMetric.java

License:Open Source License

/**
 * Returns now in RFC3339 format. This is the end-time of the window
 * this example views the TimeSeries in.
 *///from w ww  .j  ava2 s.  c o  m
private static String getNow() {
    DateTime dt = new DateTime();
    return rfc3339.format(dt.toDate());
}

From source file:CreateCustomMetric.java

License:Open Source License

/**
 * Returns 5 minutes before now to create a window to view timeseries in.
 *///from w ww . j  av a2 s.  c om
private static String getStartTime() {
    DateTime dt = new DateTime().minusMinutes(5);
    return rfc3339.format(dt.toDate());
}

From source file:DDTDate.java

License:Apache License

/**
 * Initializes the instance's referenceDate with the 'Server' date (datetime stamp adjusted by timezone adjustment)
 *///from  w  w  w  .  ja va2 s  .  com
private void initializeReferenceDate() {
    initializeLocale();
    DateTime result = new DateTime();
    int timeZoneAdjustmentInHours = DDTSettings.Settings().getTimeZoneAdjustmentInHours();
    setReferenceDate(result.plusHours(timeZoneAdjustmentInHours).toMutableDateTime());
}

From source file:SSHExecutorSubClass.java

private String getOutFileName(Job job) {

    String outFileName = "";
    outFileName += this.getSSHHost() + ".";
    outFileName += fmt.print(new DateTime());
    outFileName += "." + job.getJobName();
    //outFileName += "."+this.uuid.toString();
    //System.out.println(outFileName);
    return outFileName;
}

From source file:SSHExecutorSubClass.java

@Override
public void connected(SexecConnectedEvent e) {
    //System.out.println(e.description);
    if (this.shouldWriteStatus) {
        System.out.println(fmt.print(new DateTime()) + " - " + this.getSSHHost() + " connected ...");
    }//from w w w.ja  v  a2s.com
}

From source file:SSHExecutorSubClass.java

@Override
public void disconnected(SexecDisconnectedEvent e) {
    //System.out.println(e.description);
    if (this.shouldWriteStatus) {
        System.out.println(fmt.print(new DateTime()) + " - " + this.getSSHHost() + " disconnected ...");
    }//w  w w .j  a v  a  2  s.c  om
}

From source file:SSHExecutorSubClass.java

@Override
public void run() {

    // loop forever ...
    while (!shouldQuit) {

        // get a job from the job queue
        try {/* w ww .j a  v a  2s. c  o m*/
            this.job = this.jobQueue.take();

        } catch (InterruptedException e) {

            // if there's a problem just exit
            e.printStackTrace();
            return;
        }

        // got a job, now init stdout files for job
        this.initOutputFiles(this.job);

        // send the job to the host
        try {

            this.isWorkingOnJob = true;

            // set the start time for execution
            this.job.startTime = new DateTime();

            // do the damn thing ...
            this.sendCommand(this.job.getJob());

            // set the stop time
            this.job.stopTime = new DateTime();

            // update avg run time and numJobsExecuted
            this.updateStats(this.job);

            // comfort signal
            System.out.println(fmt.print(new DateTime()) + " - " + this.getSSHHost() + ": finished "
                    + this.job.getJobName() + " in " + this.job.getExecutionTime() + " mins");

            // that's all folks
            this.job = null;
            this.isWorkingOnJob = false;

        } catch (IPWorksSSHException e) {

            // if there is a problem with job execution
            // just print the error
            // requeue the job
            // and exit host thread. 
            e.printStackTrace();
            this.isWorkingOnJob = false;
            this.job = null;

            // Requeue the job
            try {

                // put job back in the job queue
                this.jobQueue.put(this.job);
                this.isWorkingOnJob = false;
                return;

            } catch (InterruptedException e1) {

                // could not put the job back in the job queue
                e1.printStackTrace();
                this.isWorkingOnJob = false;
                return;
            }

        } finally {
            // no matter what, close the output files ...
            this.closeOutputFiles();
            this.isWorkingOnJob = false;
        }

        this.isWorkingOnJob = false;
        this.job = null;
    }
}