List of usage examples for org.joda.time DateTime toString
@ToString
public String toString()
From source file:ca.ualberta.physics.cssdp.util.JSONDateTimeSerializer.java
License:Apache License
@Override public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(value.toString()); }
From source file:ch.icclab.cyclops.client.CloudStackPuller.java
License:Open Source License
/** * Will determine when was the last entry point (pull from CloudStack), or even if there was any * * @return date object of the last commit, or epoch if there was none *///from ww w . ja v a2 s.co m private DateTime whenWasLastPull() { DateTime last; LatestPullORM pull = (LatestPullORM) HibernateClient.getInstance().getObject(LatestPullORM.class, 1l); if (pull == null) { last = new DateTime(0); } else { last = new DateTime(pull.getTimeStamp()); } logger.trace("Getting the last pull date " + last.toString()); // get date specified by admin String date = settings.getCloudStackImportFrom(); if (date != null && !date.isEmpty()) { try { logger.trace("Admin provided us with import date preference " + date); DateTime selection = Time.getDateForTime(date); // if we are first time starting and having Epoch, change it to admin's selection // otherwise skip admin's selection and continue from the last DB entry time if (last.getMillis() == 0) { logger.debug("Setting first import date as configuration file dictates."); last = selection; } } catch (Exception ignored) { // ignoring configuration preference, as admin didn't provide correct format logger.debug("Import date selection for CloudStack ignored - use yyyy-MM-dd format"); } } return last; }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.client.CloudStackPuller.java
License:Open Source License
/** * Will determine when was the last entry point (pull from CloudStack), or even if there was any * * @return date object of the last commit, or epoch if there was none *///www . ja v a 2s . c o m private DateTime whenWasLastPull() { DateTime last = new InfluxDBClient().getLastPull(); logger.trace("Getting the last pull date " + last.toString()); // get date specified by admin String date = settings.getCloudStackImportFrom(); if (date != null && !date.isEmpty()) { try { logger.trace("Admin provided us with import date preference " + date); DateTime selection = Time.getDateForTime(date); // if we are first time starting and having Epoch, change it to admin's selection // otherwise skip admin's selection and continue from the last DB entry time if (last.getMillis() == 0) { logger.debug("Setting first import date as configuration file dictates."); last = selection; } } catch (Exception ignored) { // ignoring configuration preference, as admin didn't provide correct format logger.debug("Import date selection for CloudStack ignored - use yyyy-MM-dd format"); } } return last; }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.util.Time.java
License:Open Source License
/** * Normalise date in string format// w w w. j a v a 2 s. c om * * @param original string * @return normalised string */ public static String normaliseString(String original) { try { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm").withLocale(Locale.ROOT) .withChronology(ISOChronology.getInstanceUTC()); // and now parse it DateTime dt = formatter.parseDateTime(original); return dt.toString(); } catch (Exception ignored) { return original; } }
From source file:ch.icclab.cyclops.util.DateInterval.java
License:Open Source License
/** * Will determine when was the last entry point (pull from Ceilometer), or even if there was any * * @return date object of the last commit, or epoch if there was none *///from ww w .j a va 2 s . com private DateTime whenWasLastPull() { DateTime last; LatestPullORM pull = (LatestPullORM) HibernateClient.getInstance().getObject(LatestPullORM.class, 1l); if (pull == null) { last = new DateTime(0); } else { last = new DateTime(pull.getTimeStamp()); } logger.trace("Getting the last pull date " + last.toString()); // get date specified by admin String date = Loader.getSettings().getOpenStackSettings().getFirstImport(); if (date != null && !date.isEmpty()) { try { logger.trace("Admin provided us with import date preference " + date); DateTime selection = Time.getDateForTime(date); // if we are first time starting and having Epoch, change it to admin's selection // otherwise skip admin's selection and continue from the last DB entry time if (last.getMillis() == 0) { logger.debug("Setting first import date as configuration file dictates."); last = selection; } } catch (Exception ignored) { // ignoring configuration preference, as admin didn't provide correct format logger.debug("Import date selection for Ceilometer ignored - use yyyy-MM-dd'T'HH:mm:ssZ format"); } } DateTime dateTime = last.toDateTime(DateTimeZone.UTC); return dateTime; }
From source file:ch.rasc.portaldemos.scheduler.ISO8601DateTimeSerializer.java
License:Apache License
@Override public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(value.toString()); }
From source file:ch.windmobile.server.social.mongodb.ChatServiceImpl.java
License:Open Source License
@Override public Message postMessage(String chatRoomId, String pseudo, String text, String emailHash) { String collectionName = computeCollectionName(chatRoomId); DBCollection col = getOrCreateCappedCollection(collectionName); DBObject chatItem = new BasicDBObject(); Double id = (Double) db.eval(counter, chatRoomId); chatItem.put("_id", id.longValue()); chatItem.put(MongoDBConstants.CHAT_PROP_TEXT, text); chatItem.put(MongoDBConstants.CHAT_PROP_USER, pseudo); DateTime date = new DateTime().toDateTimeISO(); chatItem.put(MongoDBConstants.CHAT_PROP_TIME, date.toString()); chatItem.put(MongoDBConstants.CHAT_PROP_EMAIL_HASH, emailHash); col.insert(chatItem);// www . ja v a 2 s. c o m Message message = new Message(); message.setId(id.toString()); message.setDate(date); message.setPseudo(pseudo); message.setText(text); message.setEmailHash(emailHash); return message; }
From source file:coffeepot.bean.wr.writer.customHandler.DateTimeHandler.java
License:Apache License
@Override public String toString(DateTime obj) { if (obj == null) return null; return obj.toString(); }
From source file:com.actimem.blog.gson.custometypeannotation.DateTimeTypeAdapter.java
License:Apache License
@Override public void write(JsonWriter out, DateTime value) throws IOException { out.value(value.toString()); }
From source file:com.actimem.blog.gson.customtypes.DateTimeAdapter.java
License:Apache License
@Override public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.toString()); }