Example usage for org.joda.time DateTime toString

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

Introduction

In this page you can find the example usage for org.joda.time DateTime 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:com.almende.eve.transport.tokens.TokenRet.java

License:Apache License

/**
 * Instantiates a new token ret./*from w  w  w . j a v a 2  s . com*/
 * 
 * @param token
 *            the token
 * @param time
 *            the time
 */
public TokenRet(final String token, final DateTime time) {
    this.token = token;
    this.time = time.toString();
}

From source file:com.almende.eve.transport.tokens.TokenStore.java

License:Apache License

/**
 * Creates the./*from w  w  w. j  av  a 2  s . com*/
 * 
 * @return the token ret
 */
public TokenRet create() {
    TokenRet result;
    if (tokens.size() == 0 || tokens.get(last.toString()) == null || last.plus(3600000).isBeforeNow()) {
        final DateTime now = DateTime.now();
        final String token = new UUID().toString();
        result = new TokenRet(token, now);
        tokens.put(now.toString(), token);
        last = now;

        if (tokens.size() > SIZE + 2) {
            DateTime oldest = last;
            for (final String time : tokens.keySet()) {
                try {
                    if (DateTime.parse(time).isBefore(oldest)) {
                        oldest = DateTime.parse(time);
                    }
                } catch (final Exception e) {
                    LOG.log(Level.WARNING, "Failed in eviction of tokens:", e);
                }
            }
            tokens.remove(oldest.toString());
        }
    } else {
        result = new TokenRet(tokens.get(last.toString()), last);
    }
    return result;
}

From source file:com.almende.util.tokens.TokenStore.java

License:Apache License

/**
 * Creates the.//from   ww w. j  a  v  a  2s .  com
 *
 * @return the token ret
 */
public static TokenRet create() {
    synchronized (tokens) {
        TokenRet result;
        if (tokens.size() == 0 || tokens.get(last.toString(), String.class) == null
                || last.plus(3600000).isBeforeNow()) {
            final DateTime now = DateTime.now();
            final String token = new UUID().toString();
            result = new TokenRet(token, now);
            tokens.put(now.toString(), token);
            last = now;

            if (tokens.size() > SIZE + 2) {
                DateTime oldest = last;
                for (final String time : tokens.keySet()) {
                    try {
                        if (time.equals(State.KEY_AGENT_TYPE)) {
                            continue;
                        }
                        if (DateTime.parse(time).isBefore(oldest)) {
                            oldest = DateTime.parse(time);
                        }
                    } catch (final Exception e) {
                        LOG.log(Level.WARNING, "Failed in eviction of tokens:", e);
                    }
                }
                tokens.remove(oldest.toString());
            }
        } else {
            result = new TokenRet(tokens.get(last.toString(), String.class), last);
        }
        return result;
    }
}

From source file:com.att.ajsc.common.utility.DateUtility.java

License:BSD License

public static String toIsoString(Date date) {
    DateTime dateTime = new DateTime(date);
    return dateTime.toString();
}

From source file:com.att.ajsc.common.utility.DateUtility.java

License:BSD License

public static String nowAsIsoString() {
    DateTime dateTime = new DateTime();
    return dateTime.toString();
}

From source file:com.barchart.feed.base.instrument.enums.MarketDisplay.java

License:BSD License

/** in default time zone */
public static final String timeTextISO(final TimeValue value) {
    final long millisUTC = value.asMillisUTC();
    final DateTime time = new DateTime(millisUTC);
    return time.toString();
}

From source file:com.barchart.feed.base.provider.MarketDisplayBaseImpl.java

License:BSD License

@Override
public String timeTextISO(TimeValue value) {
    final long millisUTC = value.asMillisUTC();
    final DateTime time = new DateTime(millisUTC);
    return time.toString();
}

From source file:com.barchart.feed.ddf.historical.api.DDF_Query.java

License:BSD License

private final CharSequence renderTime(/* local */DateTime time) {
    if (time == null) {
        time = NULL_TIME;/* w ww  .  j ava  2 s  .c  om*/
    }
    if (instrument == null) {
        return time.toString();
    } else {
        final DateTimeZone zone = DateTimeZone.forOffsetMillis((int) (instrument.timeZoneOffset()));
        return time.withZone(zone).toString();
    }
}

From source file:com.chiorichan.dvr.VideoWriter.java

License:Mozilla Public License

private void frameHandler(DateTime dt, BufferedImage img) {
    try {// ww  w . j ava 2  s  .  c o m
        if (img == null)
            return;

        frameEncoding = true;

        long start = System.currentTimeMillis();

        if (lastTen != storageInterface.getTen(dt)) {
            lastTen = storageInterface.getTen(dt);
            changeDestFile();
        }

        containerStream.putNextEntry(new ZipEntry(dt.getMillis() + ".jpg"));

        ByteArrayOutputStream bs = new ByteArrayOutputStream();
        ImageIO.write(img, "JPG", bs);

        containerStream.write(bs.toByteArray());

        containerStream.closeEntry();

        Loader.getLogger()
                .info(ChatColor.YELLOW + "Writing Frame: Capture Time: " + dt.toString() + ", File Size: "
                        + bs.size() + " bytes, Frames Buffered: " + timeCodedFrames.size() + ", Time Taken: "
                        + (System.currentTimeMillis() - start) + ", Thread: "
                        + Thread.currentThread().getName());

        frameEncoding = false;
    } catch (IOException ex) {
        Loader.getLogger().severe("Exception encountered within the frameHandler method:", ex);
    }
}

From source file:com.claresco.tinman.servlet.XapiServletSimpleErrorLogger.java

License:Open Source License

protected long log(Exception theException, int errorNumber, String errorMessage) {
    DateTime theDate = DateTime.now();

    long theReturnedValue = logID;

    //String fileName = theDate.year().getAsShortText() + "-" + theDate.monthOfYear()
    //      .getAsString() + "-" +theDate.dayOfMonth().getAsShortText() + ".txt";
    String fileName = myFileName;

    File theLogFile = new File(myPath + fileName);

    try {/*  ww  w.j  a va 2  s.c  o m*/
        if (!theLogFile.exists()) {
            theLogFile.createNewFile();
        }

        PrintWriter theWriter = new PrintWriter(new BufferedWriter(new FileWriter(myPath + fileName, true)));

        theWriter.println("===============================================================");
        theWriter.println(logID);
        theWriter.println(theDate.toString());
        logID++;
        theException.printStackTrace(theWriter);
        theWriter.println(errorNumber + " : " + errorMessage);
        theWriter.println("===============================================================\n\n\n");

        theWriter.close();

        return theReturnedValue;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return -1;
}