Search in sources :

Example 96 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project dhis2-core by dhis2.

the class AbstractCalendar method formattedIsoDate.

@Override
public String formattedIsoDate(DateTimeUnit dateTimeUnit) {
    dateTimeUnit = toIso(dateTimeUnit);
    DateTime dateTime = dateTimeUnit.toJodaDateTime();
    DateTimeFormatter format = DateTimeFormat.forPattern(getDateFormat());
    return format.print(dateTime);
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 97 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project dhis2-core by dhis2.

the class AbstractCalendar method toIso.

@Override
public DateTimeUnit toIso(String date) {
    DateTimeFormatter format = DateTimeFormat.forPattern(getDateFormat());
    DateTime dateTime = format.parseDateTime(date);
    return toIso(DateTimeUnit.fromJodaDateTime(dateTime));
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 98 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project dhis2-core by dhis2.

the class MetadataSyncPreProcessorTest method testShouldGetLatestMetadataVersionForTheGivenVersionList.

@Test
public void testShouldGetLatestMetadataVersionForTheGivenVersionList() throws ParseException {
    MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ssZ");
    MetadataVersion currentVersion = new MetadataVersion();
    currentVersion.setType(VersionType.BEST_EFFORT);
    currentVersion.setName("test_version1");
    currentVersion.setCreated(new Date());
    currentVersion.setHashCode("samplehashcode1");
    MetadataVersion version2 = new MetadataVersion("Version2", VersionType.ATOMIC);
    org.joda.time.DateTime dateTime = dateTimeFormatter.parseDateTime("2016-06-21 10:45:50Z");
    version2.setCreated(dateTime.toDate());
    MetadataVersion version3 = new MetadataVersion("Version3", VersionType.ATOMIC);
    org.joda.time.DateTime dateTime2 = dateTimeFormatter.parseDateTime("2016-06-21 10:45:54Z");
    version3.setCreated(dateTime2.toDate());
    MetadataVersion version4 = new MetadataVersion("Version4", VersionType.ATOMIC);
    org.joda.time.DateTime dateTime3 = dateTimeFormatter.parseDateTime("2016-06-21 10:45:58Z");
    version4.setCreated(dateTime3.toDate());
    List<MetadataVersion> metadataVersionList = new ArrayList<>();
    metadataVersionList.add(version2);
    metadataVersionList.add(version3);
    metadataVersionList.add(version4);
    when(metadataVersionDelegate.getMetaDataDifference(currentVersion)).thenReturn(metadataVersionList);
    List<MetadataVersion> expectedListOfVersions = metadataSyncPreProcessor.handleMetadataVersionsList(mockRetryContext, currentVersion);
    verify(systemSettingManager).saveSystemSetting(SettingKey.REMOTE_METADATA_VERSION, version4.getName());
    assertEquals(3, expectedListOfVersions.size());
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) MetadataRetryContext(org.hisp.dhis.dxf2.metadata.tasks.MetadataRetryContext) ArrayList(java.util.ArrayList) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Date(java.util.Date) IntegrationTest(org.hisp.dhis.IntegrationTest) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 99 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project zeppelin by apache.

the class NotebookServer method moveFolderToTrash.

private void moveFolderToTrash(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws SchedulerException, IOException {
    String folderId = (String) fromMessage.get("id");
    if (folderId == null) {
        return;
    }
    Folder folder = notebook.getFolder(folderId);
    if (folder != null && !folder.isTrash()) {
        String trashFolderId = Folder.TRASH_FOLDER_ID + "/" + folderId;
        if (notebook.hasFolder(trashFolderId)) {
            DateTime currentDate = new DateTime();
            DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
            trashFolderId += Folder.TRASH_FOLDER_CONFLICT_INFIX + formatter.print(currentDate);
        }
        fromMessage.put("name", trashFolderId);
        renameFolder(conn, userAndRoles, notebook, fromMessage, "move");
    }
}
Also used : Folder(org.apache.zeppelin.notebook.Folder) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 100 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project druid by druid-io.

the class DataSegmentUtils method parse.

private static SegmentIdentifierParts parse(String dataSource, String identifier) {
    if (!identifier.startsWith(String.format("%s_", dataSource))) {
        LOGGER.info("Invalid identifier %s", identifier);
        return null;
    }
    String remaining = identifier.substring(dataSource.length() + 1);
    String[] splits = remaining.split(DataSegment.delimiter);
    if (splits.length < 3) {
        LOGGER.info("Invalid identifier %s", identifier);
        return null;
    }
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    DateTime start = formatter.parseDateTime(splits[0]);
    DateTime end = formatter.parseDateTime(splits[1]);
    String version = splits[2];
    String trail = splits.length > 3 ? join(splits, DataSegment.delimiter, 3, splits.length) : null;
    return new SegmentIdentifierParts(dataSource, new Interval(start.getMillis(), end.getMillis()), version, trail);
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval)

Aggregations

DateTimeFormatter (org.joda.time.format.DateTimeFormatter)189 DateTime (org.joda.time.DateTime)88 Date (java.util.Date)40 Test (org.junit.Test)25 DateTimeZone (org.joda.time.DateTimeZone)19 ArrayList (java.util.ArrayList)14 SolrInputDocument (org.apache.solr.common.SolrInputDocument)12 IndexSchema (org.apache.solr.schema.IndexSchema)12 DateTimeFormatterBuilder (org.joda.time.format.DateTimeFormatterBuilder)12 HashMap (java.util.HashMap)10 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)10 IOException (java.io.IOException)9 Calendar (java.util.Calendar)8 Map (java.util.Map)8 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)7 FormatDateTimeFormatter (org.elasticsearch.common.joda.FormatDateTimeFormatter)7 Test (org.testng.annotations.Test)7 TimeSpec (com.linkedin.thirdeye.api.TimeSpec)6 FilterType (net.opengis.filter.v_1_1_0.FilterType)6 Deployment (org.activiti.engine.test.Deployment)6