Example usage for org.joda.time LocalDate parse

List of usage examples for org.joda.time LocalDate parse

Introduction

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

Prototype

@FromString
public static LocalDate parse(String str) 

Source Link

Document

Parses a LocalDate from the specified string.

Usage

From source file:org.kitodo.production.model.bibliography.course.Course.java

License:Open Source License

private IndividualIssue prepareIndividualIssue(Element issueNode, String variant) {
    String issue = issueNode.getAttribute(ATTRIBUTE_ISSUE_HEADING);
    String date = issueNode.getAttribute(ATTRIBUTE_DATE);
    if (date == null) {
        throw new NullPointerException(ATTRIBUTE_DATE);
    }//from   ww  w  .ja va2 s.c  o m
    return addAddition(variant, issue, LocalDate.parse(date));
}

From source file:org.mythtv.db.dvr.ProgramDaoHelper.java

License:Open Source License

/**
 * @param cursor/*from w  w w.j ava2  s.co  m*/
 * @return
 */
public static Program convertCursorToProgram(Cursor cursor, final String table) {
    //      Log.v( TAG, "convertCursorToProgram : enter" );

    //      Long id = null;
    DateTime startTime = null, endTime = null, lastModified = null;
    String title = "", subTitle = "", category = "", categoryType = "", seriesId = "", programId = "",
            hostname = "", filename = "", description = "", inetref = "", masterHostname = "", airDate = "";
    int repeat = -1, videoProps = -1, audioProps = -1, subProps = -1, season = -1, episode = -1,
            programFlags = -1;
    long fileSize = -1;
    Double stars = 0.0;

    ChannelInfo channelInfo = null;
    RecordingInfo recording = null;
    LiveStreamInfo liveStreamInfo = null;

    //      if( cursor.getColumnIndex( ProgramConstants._ID ) != -1 ) {
    //         id = cursor.getLong( cursor.getColumnIndex( ProgramConstants._ID ) );
    //      }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_START_TIME) != -1) {
        startTime = new DateTime(cursor.getLong(cursor.getColumnIndex(ProgramConstants.FIELD_START_TIME)));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_END_TIME) != -1) {
        endTime = new DateTime(cursor.getLong(cursor.getColumnIndex(ProgramConstants.FIELD_END_TIME)));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_TITLE) != -1) {
        title = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_TITLE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_SUB_TITLE) != -1) {
        subTitle = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_SUB_TITLE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_CATEGORY) != -1) {
        category = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_CATEGORY));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_CATEGORY_TYPE) != -1) {
        categoryType = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_CATEGORY_TYPE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_REPEAT) != -1) {
        repeat = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_REPEAT));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_VIDEO_PROPS) != -1) {
        videoProps = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_VIDEO_PROPS));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_AUDIO_PROPS) != -1) {
        audioProps = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_AUDIO_PROPS));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_SUB_PROPS) != -1) {
        subProps = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_SUB_PROPS));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_SERIES_ID) != -1) {
        seriesId = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_SERIES_ID));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_PROGRAM_ID) != -1) {
        programId = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_PROGRAM_ID));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_STARS) != -1) {
        stars = cursor.getDouble(cursor.getColumnIndex(ProgramConstants.FIELD_STARS));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_FILE_SIZE) != -1) {
        fileSize = cursor.getLong(cursor.getColumnIndex(ProgramConstants.FIELD_FILE_SIZE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_LAST_MODIFIED) != -1) {
        lastModified = new DateTime(
                cursor.getLong(cursor.getColumnIndex(ProgramConstants.FIELD_LAST_MODIFIED)));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_PROGRAM_FLAGS) != -1) {
        programFlags = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_PROGRAM_FLAGS));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_HOSTNAME) != -1) {
        hostname = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_HOSTNAME));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_FILENAME) != -1) {
        filename = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_FILENAME));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_AIR_DATE) != -1) {
        airDate = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_AIR_DATE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_DESCRIPTION) != -1) {
        description = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_DESCRIPTION));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_INETREF) != -1) {
        inetref = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_INETREF));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_SEASON) != -1) {
        season = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_SEASON));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_EPISODE) != -1) {
        episode = cursor.getInt(cursor.getColumnIndex(ProgramConstants.FIELD_EPISODE));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_MASTER_HOSTNAME) != -1) {
        masterHostname = cursor.getString(cursor.getColumnIndex(ProgramConstants.FIELD_MASTER_HOSTNAME));
    }

    if (cursor.getColumnIndex(ProgramConstants.FIELD_CHANNEL_ID) != -1) {
        channelInfo = ChannelDaoHelper.convertCursorToChannelInfo(cursor);
    }

    if (cursor.getColumnIndex(RecordingConstants.ContentDetails.getValueFromParent(table).getTableName() + "_"
            + RecordingConstants.FIELD_RECORD_ID) != -1) {
        recording = RecordingDaoHelper.convertCursorToRecording(cursor, table);
    }

    if (cursor.getColumnIndex(LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_ID) != -1) {
        liveStreamInfo = LiveStreamDaoHelper.convertCursorToLiveStreamInfo(cursor);
    }

    Program program = new Program();
    program.setStartTime(startTime);
    program.setEndTime(endTime);
    program.setTitle(title);
    program.setSubTitle(subTitle);
    program.setCategory(category);
    program.setCategory(categoryType);
    program.setRepeat(repeat == 1 ? true : false);
    program.setVideoProps(videoProps);
    program.setAudioProps(audioProps);
    program.setSubProps(subProps);
    program.setSeriesId(seriesId);
    program.setProgramId(programId);
    program.setStars(stars);
    program.setFileSize(fileSize);
    program.setLastModified(lastModified);
    program.setProgramFlags(programFlags);
    program.setHostName(hostname);
    program.setFileName(filename);
    program.setAirdate(LocalDate.parse(airDate));
    program.setDescription(description);
    program.setInetref(inetref);
    program.setSeason(season);
    program.setEpisode(episode);
    program.setChannel(channelInfo);
    program.setRecording(recording);

    //      Log.v( TAG, "convertCursorToProgram : id=" + id + ", program=" + program.toString() );

    //      Log.v( TAG, "convertCursorToProgram : exit" );
    return program;
}

From source file:org.ojai.types.ODate.java

License:Apache License

/**
 * Parses and return an instance of {@code ODate} from the specified string.
 * @param dateStr  the string to parse//from   w  w w .  j a v  a  2  s . com
 * @exception ParseException if the beginning of the specified string
 *            cannot be parsed.
 */
public static ODate parse(String dateStr) {
    try {
        return new ODate(LocalDate.parse(dateStr));
    } catch (IllegalArgumentException e) {
        throw new ParseException(e);
    }
}

From source file:org.projectbuendia.client.json.LocalDateSerializer.java

License:Apache License

@Override
public LocalDate deserialize(JsonElement json, Type type, JsonDeserializationContext context)
        throws JsonParseException {
    String text = json.getAsString();
    try {//from  ww  w . ja  v  a 2s.co  m
        return LocalDate.parse(text);
    } catch (IllegalArgumentException e) {
        throw new JsonParseException(e);
    }
}

From source file:org.projectbuendia.client.utils.date.Dates.java

License:Apache License

/** Converts a yyyy-mm-dd String to a LocalDate. */
@Nullable//from   ww w  .ja  v  a  2  s.c  om
public static LocalDate toLocalDate(@Nullable String string) {
    try {
        return string == null ? null : LocalDate.parse(string);
    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:org.projectbuendia.client.utils.Utils.java

License:Apache License

/** Converts a nullable yyyy-mm-dd String to a LocalDate. */
public static @Nullable LocalDate toLocalDate(@Nullable String string) {
    try {//from w w  w .j av  a 2 s. com
        return string == null ? null : LocalDate.parse(string);
    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:org.supercsv.cellprocessor.joda.ParseLocalDate.java

License:Apache License

/**
 * {@inheritDoc}
 */
@Override
protected LocalDate parse(final String string) {
    return LocalDate.parse(string);
}

From source file:pl.porannajava.javnysejm.support.StringConverter.java

License:Apache License

public static LocalDate getDate(String input) {
    return LocalDate.parse(normalizeString(input));
}

From source file:se.inera.certificate.schema.adapter.LocalDateAdapter.java

License:Open Source License

/**
 * Converts an intyg:common-model:1:date to a Joda Time LocalDate.
 *///www . ja  v  a2 s .c  o m
public static LocalDate parseIsoDate(String dateString) {
    return LocalDate.parse(dateString);
}

From source file:se.inera.intyg.intygstjanst.web.integration.rehabstod.converter.SjukfallCertificateIntygsDataConverter.java

License:Open Source License

private Formaga buildFormaga(SjukfallCertificateWorkCapacity wc) {
    Formaga formaga = new Formaga();
    formaga.setNedsattning(wc.getCapacityPercentage());
    formaga.setStartdatum(LocalDate.parse(wc.getFromDate()));
    formaga.setSlutdatum(LocalDate.parse(wc.getToDate()));
    return formaga;
}