Search in sources :

Example 1 with Date

use of org.eclipse.mylyn.docs.epub.dc.Date in project mylyn.docs by eclipse.

the class Publication method addDate.

/**
 * Date of publication, in the format defined by the W3C specification "<a href="http://www.w3.org/TR/NOTE-datetime
 * ">Date and Time Formats</a>" and by ISO 8601. In particular, dates without times must be represented in the form
 * YYYY[-MM[-DD]]: a required 4-digit year, an optional 2-digit month, and if the month is given, an optional
 * 2-digit day of month. The event attribute is optional, possible values may include: "creation", "publication",
 * and "modification".
 *
 * @param id
 *            optional identifier
 * @param value
 *            the date string
 * @param event
 *            an optional event description
 * @return the new date
 */
public Date addDate(String id, String value, String event) {
    if (value == null) {
        // $NON-NLS-1$
        throw new IllegalArgumentException("A value must be specified");
    }
    Date dc = DCFactory.eINSTANCE.createDate();
    setDcCommon(dc, id, value);
    if (event != null) {
        dc.setEvent(event);
    }
    opfPackage.getMetadata().getDates().add(dc);
    return dc;
}
Also used : Date(org.eclipse.mylyn.docs.epub.dc.Date)

Example 2 with Date

use of org.eclipse.mylyn.docs.epub.dc.Date in project mylyn.docs by eclipse.

the class PublicationProxy method getPublicationDate.

@SuppressWarnings("rawtypes")
public String getPublicationDate() {
    EList<Date> dates = publication.getPackage().getMetadata().getDates();
    if (dates.size() > 0) {
        for (Date date : dates) {
            if (date.getEvent().equals("publication")) {
                // $NON-NLS-1$
                FeatureMap fm = date.getMixed();
                Object o = fm.get(TEXT, false);
                if (o instanceof FeatureEList) {
                    if (((FeatureEList) o).size() > 0) {
                        return ((FeatureEList) o).get(0).toString();
                    }
                }
            }
        }
    }
    return EMPTY_STRING;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) FeatureEList(org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList) Date(org.eclipse.mylyn.docs.epub.dc.Date)

Example 3 with Date

use of org.eclipse.mylyn.docs.epub.dc.Date in project mylyn.docs by eclipse.

the class Publication method addDate.

/**
 * Adds a new date to the publication. The given instance will be represented in a format defined by
 * "Date and Time Formats" at http://www.w3.org/TR/NOTE-datetime and by ISO 8601 on which it is based.
 *
 * @param id
 *            optional identifier
 * @param date
 *            the date
 * @param event
 *            the event
 * @return the new date
 * @see #addDate(String, String, String)
 */
public Date addDate(String id, java.util.Date date, String event) {
    // $NON-NLS-1$
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    // $NON-NLS-1$
    TimeZone tz = TimeZone.getTimeZone("UTC");
    df.setTimeZone(tz);
    Date dc = DCFactory.eINSTANCE.createDate();
    setDcCommon(dc, id, df.format(date));
    if (event != null) {
        dc.setEvent(event);
    }
    opfPackage.getMetadata().getDates().add(dc);
    return dc;
}
Also used : TimeZone(java.util.TimeZone) SimpleDateFormat(java.text.SimpleDateFormat) Date(org.eclipse.mylyn.docs.epub.dc.Date)

Aggregations

Date (org.eclipse.mylyn.docs.epub.dc.Date)3 SimpleDateFormat (java.text.SimpleDateFormat)1 TimeZone (java.util.TimeZone)1 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)1 FeatureEList (org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList)1