Example usage for org.joda.time DateTime toDateTime

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

Introduction

In this page you can find the example usage for org.joda.time DateTime toDateTime.

Prototype

public DateTime toDateTime(Chronology chronology) 

Source Link

Document

Get this object as a DateTime, returning this if possible.

Usage

From source file:ee.ria.xroad.confproxy.util.OutputBuilder.java

License:Open Source License

/**
 * Generates global configuration directory content MIME.
 * @param mimeContent output stream to write to
 * @throws Exception if reading global configuration files fails
 *///  w w  w  .j  a v a2 s  .co  m
private void build(final ByteArrayOutputStream mimeContent) throws Exception {
    try (MultipartEncoder encoder = new MultipartEncoder(mimeContent, dataBoundary)) {
        DateTime expireDate = new DateTime().plusSeconds(conf.getValidityIntervalSeconds());
        encoder.startPart(null,
                new String[] { HEADER_EXPIRE_DATE + ": " + expireDate.toDateTime(DateTimeZone.UTC),
                        HEADER_VERSION + ": " + String.format("%d", version) });

        String instance = conf.getInstance();

        confDir.eachFile((metadata, inputStream) -> {
            try (FileOutputStream fos = createFileOutputStream(tempDirPath, metadata)) {
                TeeInputStream tis = new TeeInputStream(inputStream, fos);
                appendFileContent(encoder, instance, metadata, tis);
            }
        });
    }
}

From source file:eu.hydrologis.jgrass.geonotes.util.ExifHandler.java

License:Open Source License

/**
 * Extract the creation {@link DateTime} from the map of tags read by {@link #readMetaData(File)}.
 * //from w  w w . j  a  va 2s  . c  om
 * @param tags2ValuesMap the map of tags read by {@link #readMetaData(File)}.
 * @return the datetime.
 */
public static DateTime getCreationDatetimeUtc(HashMap<String, String> tags2ValuesMap) {
    String creationDate = tags2ValuesMap.get(TiffConstants.EXIF_TAG_CREATE_DATE.name);
    creationDate = creationDate.replaceAll("'", "");
    creationDate = creationDate.replaceFirst(":", "-");
    creationDate = creationDate.replaceFirst(":", "-");

    String dateTimeFormatterYYYYMMDDHHMMSS_string = "yyyy-MM-dd HH:mm:ss";
    DateTimeFormatter dateTimeFormatterYYYYMMDDHHMMSS = DateTimeFormat
            .forPattern(dateTimeFormatterYYYYMMDDHHMMSS_string);

    DateTime parseDateTime = dateTimeFormatterYYYYMMDDHHMMSS.parseDateTime(creationDate);
    DateTime dt = parseDateTime.toDateTime(DateTimeZone.UTC);
    return dt;
}

From source file:eu.hydrologis.jgrass.gpsnmea.db.DatabaseManager.java

License:Open Source License

/**
 * Retrieves the list of {@link GpsPoint points} between two given dates.
 * //from   w  w w.ja va 2  s. co m
 * @param from start {@link DateTime}. Can be null, in which case 
 *                          1970-01-01 00:00 will be used.
 * @param to end {@link DateTime}. Can be null, in which case 
 *                          3000-01-01 00:00 will be used.
 * @return the list of points.
 * @throws Exception
 */
public List<GpsPoint> getGpsPointBetweenTimeStamp(DateTime from, DateTime to) throws Exception {

    if (from == null) {
        from = defaultFrom;
    }
    if (to == null) {
        to = defaultTo;
    }

    from = from.toDateTime(DateTimeZone.UTC);
    to = to.toDateTime(DateTimeZone.UTC);

    Session session = DatabasePlugin.getDefault().getActiveDatabaseConnection().openSession();
    List<GpsPoint> pointsList = new ArrayList<GpsPoint>();
    try {
        Criteria criteria = session.createCriteria(GpsLogTable.class);
        String utcTimeStr = "utcTime";
        String idStr = "id";
        criteria.add(between(utcTimeStr, from, to));
        criteria.addOrder(asc(idStr));
        criteria.addOrder(asc(utcTimeStr));

        List<GpsLogTable> resultsList = criteria.list();
        for (GpsLogTable gpsLog : resultsList) {
            NmeaGpsPoint p = new NmeaGpsPoint();
            p.utcDateTime = gpsLog.getUtcTime();
            p.longitude = gpsLog.getEast();
            p.latitude = gpsLog.getNorth();
            p.altitude = gpsLog.getAltimetry();
            pointsList.add(p);
        }
    } finally {
        session.close();
    }
    return pointsList;
}

From source file:eu.itesla_project.cases.EntsoeCaseRepository.java

License:Mozilla Public License

private static DateTime toCetDate(DateTime date) {
    DateTimeZone CET = DateTimeZone.forID("CET");
    if (!date.getZone().equals(CET)) {
        return date.toDateTime(CET);
    }//  w w w .j  av  a  2s  .  c  o  m
    return date;
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanActivity.java

License:Apache License

/**
 * internally date is stored with UTC timezone
 *
 * @param approvedTimestamp/*from  www. ja  v  a 2s.  c  o  m*/
 */
public void setApprovedTimestamp(@Nullable DateTime approvedTimestamp) {
    if (approvedTimestamp != null) {
        this.approvedTimestamp = approvedTimestamp.toDateTime(DateTimeZone.UTC);
    } else {
        this.approvedTimestamp = null;
    }
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanDataset.java

License:Apache License

/**
 * Internally date is stored with UTC timezone
 *//*from w  ww .  ja v a2s .  co  m*/
public void setMetadataCreated(DateTime metadataCreated) {
    this.metadataCreated = metadataCreated.toDateTime(DateTimeZone.UTC);
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanDataset.java

License:Apache License

/**
 * Internally date is stored with UTC timezone
 *///from   w w  w .ja  v  a  2 s .c o m
public void setMetadataModified(DateTime metadataModified) {
    this.metadataModified = metadataModified.toDateTime(DateTimeZone.UTC);
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanDataset.java

License:Apache License

/**
 * Internally date is stored with UTC timezone. Probably it is automatically
 * calculated by CKAN./*from w  w w .  j av a2 s  .com*/
 *
 * @param revisionTimestamp
 */
public void setRevisionTimestamp(DateTime revisionTimestamp) {
    this.revisionTimestamp = revisionTimestamp.toDateTime(DateTimeZone.UTC);
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanGroupStructure.java

License:Apache License

/**
 * internally date is stored with UTC timezone
 *///w  w w. j a v  a 2s  .co m
public void setCreated(DateTime created) {
    this.created = created.toDateTime(DateTimeZone.UTC);
}

From source file:eu.trentorise.opendata.jackan.ckan.CkanResource.java

License:Apache License

/**
 * Internally date is stored with UTC timezone
 *//*from w w  w  .j ava2s . c  o m*/
public void setLastModified(@Nullable DateTime lastModified) {
    if (lastModified != null) {
        this.lastModified = lastModified.toDateTime(DateTimeZone.UTC);
    } else {
        this.lastModified = null;
    }
}