Example usage for java.time LocalDateTime toLocalDate

List of usage examples for java.time LocalDateTime toLocalDate

Introduction

In this page you can find the example usage for java.time LocalDateTime toLocalDate.

Prototype

@Override
public LocalDate toLocalDate() 

Source Link

Document

Gets the LocalDate part of this date-time.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    System.out.println(a.toLocalDate().getYear());
}

From source file:Main.java

public static LocalDate getDatePart(final LocalDateTime dateTime) {
    return dateTime.toLocalDate();
}

From source file:Main.java

public static LocalDate getDateFromTimestamp(long timestamp) {
    LocalDateTime date = getDateTimeFromTimestamp(timestamp);
    return date == null ? null : date.toLocalDate();
}

From source file:com.omertron.slackbot.functions.Meetup.java

/**
 * Format the MeetUp list into a list of Slack Attachments, up to a certain number of days ahead
 *
 * @param daysAhead/*from  www. j a v  a  2 s  .c  o m*/
 * @param detailed
 * @return
 */
public static Map<LocalDateTime, SlackAttachment> getMeetupsDays(int daysAhead, boolean detailed) {
    LocalDate now = LocalDate.now();
    Map<LocalDateTime, SlackAttachment> results = new HashMap<>();

    Period diff;
    for (MeetupDetails md : MEETUPS) {
        // Correct for BST
        LocalDateTime meetTime = md.getMeetupTime().plusHours(1);

        diff = Period.between(now, meetTime.toLocalDate());
        if (diff.getDays() <= daysAhead) {
            LOG.info("Add: Days: {} - {} - {}", diff.getDays(), meetTime.format(DT_FORMAT), md.getName());
            results.put(meetTime, makeSlackAttachment(md, detailed));
        } else {
            LOG.info("Skip: Days: {} - {} - {}", diff.getDays(), meetTime.format(DT_FORMAT), md.getName());
        }
    }

    return results;
}

From source file:alfio.test.util.IntegrationTestUtil.java

public static Pair<Event, String> initEvent(List<TicketCategoryModification> categories,
        OrganizationRepository organizationRepository, UserManager userManager, EventManager eventManager,
        EventRepository eventRepository) {

    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();

    userManager.createOrganization(organizationName, "org", "email@example.com");
    Organization organization = organizationRepository.findByName(organizationName).get();
    userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR,
            User.Type.INTERNAL);
    userManager.insertUser(organization.getId(), username + "_owner", "test", "test", "test@example.com",
            Role.OWNER, User.Type.INTERNAL);

    LocalDateTime expiration = LocalDateTime.now().plusDays(5).plusHours(1);

    Map<String, String> desc = new HashMap<>();
    desc.put("en", "muh description");
    desc.put("it", "muh description");
    desc.put("de", "muh description");

    EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", "url",
            null, eventName, "event display name", organization.getId(), "muh location", "0.0", "0.0",
            ZoneId.systemDefault().getId(), desc,
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            new DateTimeModification(expiration.toLocalDate(), expiration.toLocalTime()), BigDecimal.TEN, "CHF",
            AVAILABLE_SEATS, BigDecimal.ONE, true, Collections.singletonList(PaymentProxy.OFFLINE), categories,
            false, new LocationDescriptor("", "", "", ""), 7, null, null);
    eventManager.createEvent(em);/*from   w  w w .ja va 2 s. c om*/
    Event event = eventManager.getSingleEvent(eventName, username);
    Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    return Pair.of(event, username);
}

From source file:com.romeikat.datamessie.core.base.util.publishedDates.PublishedDateStrategy.java

private Set<LocalDate> getAllPublishedDates(final SharedSessionContract ssc) {
    final List<LocalDateTime> publishedTimestamps = getAllPublishedTimestamps(ssc);
    final List<LocalDate> publishedDates = Lists.transform(publishedTimestamps,
            new Function<LocalDateTime, LocalDate>() {
                @Override// ww w .  j av a 2 s.  c  o  m
                public LocalDate apply(final LocalDateTime localDateTime) {
                    return localDateTime.toLocalDate();
                }
            });
    final Set<LocalDate> uniquePublishedDates = Sets.newHashSet(publishedDates);
    return uniquePublishedDates;
}

From source file:com.serphacker.serposcope.models.base.Run.java

public Run(Mode mode, Module module, LocalDateTime started) {
    this.mode = mode;
    this.module = module;
    this.day = started.toLocalDate();
    this.started = started;
    this.status = Status.RUNNING;
}

From source file:br.ufac.sion.dao.InscricaoFacade.java

private Map<Date, Long> criaMapaVazio(Integer numeroDeDias, LocalDateTime dataInicial) {
    Map<Date, Long> mapaInicial = new TreeMap<>();

    LocalDate dt = dataInicial.toLocalDate();

    for (int i = 0; i <= numeroDeDias; i++) {
        mapaInicial.put(DateConversor.convertLocalDateToDate(dt), 0L);
        dt = dt.plusDays(1);/*from  w  ww  .  ja v a  2  s  . c  o m*/
    }

    return mapaInicial;
}

From source file:com.romeikat.datamessie.core.processing.service.cleaning.extract.TagExctractor.java

public String extractContent(final StatelessSession statelessSession,
        final DocumentsProcessingCache documentsProcessingCache, final RawContent rawContent,
        final Document document) {
    if (rawContent == null) {
        return null;
    }//from w w w. j  a va 2 s .  co  m
    // Apply tag selecting rules
    final List<TagSelectingRule> tagSelectingRules = documentsProcessingCache
            .getTagSelectingRules(statelessSession, document.getSourceId());
    final LocalDateTime documentDownloaded = document.getDownloaded();
    // Determine active rules
    final List<TagSelectingRule> activeTagSelectingRules = new LinkedList<TagSelectingRule>();
    for (final TagSelectingRule tagSelectingRule : tagSelectingRules) {
        if (tagSelectingRule.isActive(documentDownloaded.toLocalDate())) {
            activeTagSelectingRules.add(tagSelectingRule);
        }
    }
    // Without active rules, use whole document
    if (activeTagSelectingRules.isEmpty()) {
        return rawContent.getContent();
    }
    // Process active rules one after another, until tag selection is successful
    for (final TagSelectingRule activeTagSelectingRule : activeTagSelectingRules) {
        // Extract content with tag selector
        final String tagSelector = activeTagSelectingRule.getTagSelector();
        final String extractedContent = extractContent(rawContent, document, tagSelector);
        // If successful, done
        if (extractedContent != null) {
            return extractedContent;
        }
    }
    // No unique tag found
    final List<String> tagSelectors = new LinkedList<String>();
    for (final TagSelectingRule activeTagSelectingRule : activeTagSelectingRules) {
        tagSelectors.add(activeTagSelectingRule.getTagSelector());
    }
    LOG.warn(
            "Could not extract content of document {} ({}) as none of the tag selectors {} of source {} resulted in a unique match",
            document.getId(), document.getUrl(), StringUtils.join(tagSelectors, ", "), document.getSourceId());
    return null;
}

From source file:com.romeikat.datamessie.core.base.service.DocumentService.java

private LocalDate getMinDownloadedDate(final StatelessSession statelessSession) {
    final LocalDateTime minDownloadedDateTime = documentDao.getMinDownloaded(statelessSession);
    if (minDownloadedDateTime == null) {
        return null;
    }//from  w  ww  .j  a va2s.c  om

    final LocalDate minDownloadedDate = minDownloadedDateTime.toLocalDate();
    return minDownloadedDate;
}