Example usage for org.joda.time.format ISODateTimeFormat basicDateTime

List of usage examples for org.joda.time.format ISODateTimeFormat basicDateTime

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat basicDateTime.

Prototype

public static DateTimeFormatter basicDateTime() 

Source Link

Document

Returns a basic formatter that combines a basic date and time, separated by a 'T' (yyyyMMdd'T'HHmmss.SSSZ).

Usage

From source file:org.solovyev.android.messenger.chats.ChatMapper.java

License:Apache License

@Nonnull
@Override//from w w w  .  ja  v  a2  s . c o m
public Chat convert(@Nonnull Cursor c) {
    final Entity chat = EntityMapper.newInstanceFor(0).convert(c);

    final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.basicDateTime();
    final String lastMessagesSyncDateString = c.getString(3);
    final DateTime lastMessagesSyncDate = lastMessagesSyncDateString == null ? null
            : dateTimeFormatter.parseDateTime(lastMessagesSyncDateString);

    final List<AProperty> properties = chatDao.readPropertiesById(chat.getEntityId());

    return Chats.newChat(chat, properties, lastMessagesSyncDate);
}

From source file:org.solovyev.android.messenger.chats.SqliteChatDao.java

License:Apache License

@Nonnull
private static ContentValues toContentValues(@Nonnull Chat chat) {
    final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.basicDateTime();

    final DateTime lastMessagesSyncDate = chat.getLastMessagesSyncDate();

    final ContentValues values = new ContentValues();

    values.put("id", chat.getEntity().getEntityId());
    values.put("account_id", chat.getEntity().getAccountId());
    values.put("account_chat_id", chat.getEntity().getAccountEntityId());
    values.put("last_messages_sync_date",
            lastMessagesSyncDate == null ? null : dateTimeFormatter.print(lastMessagesSyncDate));

    return values;
}

From source file:org.solovyev.android.messenger.messages.MessageMapper.java

License:Apache License

@Nonnull
@Override/* w  ww .  ja va2 s.c  om*/
public Message convert(@Nonnull Cursor cursor) {
    final Entity entity = EntityMapper.newInstanceFor(0).convert(cursor);

    final MutableMessage message = newMessage(entity);
    message.setChat(newEntityFromEntityId(cursor.getString(3)));
    message.setAuthor(newEntityFromEntityId(cursor.getString(4)));
    if (!cursor.isNull(5)) {
        final String recipientId = cursor.getString(5);
        message.setRecipient(newEntityFromEntityId(recipientId));
    }
    message.setState(MessageState.valueOf(cursor.getString(11)));
    final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.basicDateTime();

    message.setSendDate(dateTimeFormatter.parseDateTime(cursor.getString(6)));
    final Long sendTime = cursor.getLong(7);
    message.setTitle(cursor.getString(8));
    message.setBody(cursor.getString(9));

    final boolean read = cursor.getInt(10) == 1;
    message.setRead(read);

    message.setProperties(dao.readPropertiesById(entity.getEntityId()));

    return message;
}

From source file:org.solovyev.android.messenger.messages.SqliteMessageDao.java

License:Apache License

@Nonnull
private static ContentValues toContentValues(@Nonnull Message message) {
    final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.basicDateTime();

    final ContentValues values = new ContentValues();

    final Entity entity = message.getEntity();
    values.put("id", entity.getEntityId());
    values.put("account_id", entity.getAccountId());
    values.put("account_message_id", entity.getAccountEntityId());

    values.put("chat_id", message.getChat().getEntityId());
    values.put("author_id", message.getAuthor().getEntityId());
    final Entity recipient = message.getRecipient();
    values.put("recipient_id", recipient == null ? null : recipient.getEntityId());
    values.put("send_date", dateTimeFormatter.print(message.getSendDate()));
    values.put("send_time", message.getSendDate().getMillis());
    values.put("title", message.getTitle());
    values.put("body", message.getBody());
    values.put("read", message.isRead() ? 1 : 0);
    values.put("state", message.getState().name());
    return values;
}

From source file:propel.core.utils.StringUtils.java

License:Open Source License

/**
 * Returns ISO standard and other frequently used date/time parsers
 *//*from  www .  jav  a 2  s  .  c  o m*/
private static DateTimeParser[] createCommonDateTimeParsers() {
    return new DateTimeParser[] { ISODateTimeFormat.basicDateTimeNoMillis().getParser(), // yyyyMMdd'T'HHmmssZ
            ISODateTimeFormat.basicDateTime().getParser(), // yyyyMMdd'T'HHmmss.SSSZ
            ISODateTimeFormat.dateHourMinuteSecondFraction().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS (only 3 ms positions used though)
            ISODateTimeFormat.dateTimeNoMillis().getParser(), // yyyy-MM-dd'T'HH:mm:ssZZ
            ISODateTimeFormat.dateTime().getParser(), // yyyy-MM-dd'T'HH:mm:ss.SSSZZ (ISO 8601)
            DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z").getParser(), // RFC 2822
            DateTimeFormat.forPattern("yyyy/MM/dd").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd HH:mm:ss.SSSSSSSSS").getParser(),
            DateTimeFormat.forPattern("HH:mm").getParser(), DateTimeFormat.forPattern("HH:mm:ss").getParser(),
            DateTimeFormat.forPattern("HH:mm:ss.SSSSSSSSS").getParser() };
}