List of usage examples for org.joda.time LocalDate toLocalDateTime
public LocalDateTime toLocalDateTime(LocalTime time)
From source file:cherry.foundation.testtool.ToolTesterImpl.java
License:Apache License
@Override public LocalDateTime toBeInvoked3(LocalDate dt, LocalTime tm) { log.debug("method3"); return dt.toLocalDateTime(tm); }
From source file:cherry.foundation.testtool.ToolTesterImpl.java
License:Apache License
@Override public LocalDateTime toBeStubbed(LocalDate p1, LocalTime p2) { return p1.toLocalDateTime(p2); }
From source file:cherry.goods.util.LocalDateTimeUtil.java
License:Apache License
/** * (FROM)???//from w w w . ja va 2s.com * * @param from ?? * @return ????(FROM)?? */ public static LocalDateTime rangeFrom(LocalDate from) { if (from == null) { return null; } return from.toLocalDateTime(LocalTime.MIDNIGHT); }
From source file:cherry.goods.util.LocalDateTimeUtil.java
License:Apache License
/** * (FROM)???//w w w . ja v a 2s .c om * * @param fromD ?? * @param fromT ?? * @return ?????(FROM)?? */ public static LocalDateTime rangeFrom(LocalDate fromD, LocalTime fromT) { if (fromD == null) { return null; } if (fromT == null) { return fromD.toLocalDateTime(LocalTime.MIDNIGHT); } return fromD.toLocalDateTime(fromT); }
From source file:cherry.goods.util.LocalDateTimeUtil.java
License:Apache License
/** * (TO)???/* ww w .ja va 2 s .com*/ * * @param to ?? * @return ????(TO)?? */ public static LocalDateTime rangeTo(LocalDate to) { if (to == null) { return null; } return to.toLocalDateTime(LocalTime.MIDNIGHT).plusDays(1); }
From source file:cherry.goods.util.LocalDateTimeUtil.java
License:Apache License
/** * (TO)???//ww w.j a v a2s . c o m * * @param toD ?? * @param toT ?? * @return ?????(TO)?? */ public static LocalDateTime rangeTo(LocalDate toD, LocalTime toT) { if (toD == null) { return null; } if (toT == null) { return toD.toLocalDateTime(LocalTime.MIDNIGHT).plusDays(1); } return toD.toLocalDateTime(toT).plus(unitOfTime); }
From source file:com.battlelancer.seriesguide.util.TimeTools.java
License:Apache License
/** * Calculates the episode release date time as a millisecond instant. Adjusts for time zone * effects on release time, e.g. delays between time zones (e.g. in the United States) and DST. * * @param showTimeZone See {@link #getDateTimeZone(String)}. * @param showReleaseTime See {@link #getShowReleaseTime(int)}. * @return -1 if no conversion was possible. Otherwise, any other long value (may be negative!). *//*w w w . j a v a2 s .c om*/ public static long parseEpisodeReleaseDate(@NonNull DateTimeZone showTimeZone, @Nullable String releaseDate, @NonNull LocalTime showReleaseTime, @Nullable String showCountry, @NonNull String deviceTimeZone) { if (releaseDate == null || releaseDate.length() == 0) { return Constants.EPISODE_UNKNOWN_RELEASE; } // get date LocalDate localDate; try { localDate = TVDB_DATE_FORMATTER.parseLocalDate(releaseDate); } catch (IllegalArgumentException e) { // date string could not be parsed Timber.e(e, "TheTVDB date could not be parsed: " + releaseDate); return Constants.EPISODE_UNKNOWN_RELEASE; } // set time LocalDateTime localDateTime = localDate.toLocalDateTime(showReleaseTime); localDateTime = handleHourPastMidnight(showCountry, localDateTime); localDateTime = handleDstGap(showTimeZone, localDateTime); // finally get a valid datetime in the show time zone DateTime dateTime = localDateTime.toDateTime(showTimeZone); // handle time zone effects on release time for US shows (only if device is set to US zone) if (deviceTimeZone.startsWith(TIMEZONE_ID_PREFIX_AMERICA)) { dateTime = applyUnitedStatesCorrections(showCountry, deviceTimeZone, dateTime); } return dateTime.getMillis(); }
From source file:com.helger.peppol.smpserver.ui.secure.PageSecureEndpoints.java
License:Apache License
@Override protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPServiceInformation aSelectedObject, @Nonnull final FormErrors aFormErrors, @Nonnull final EWebPageFormAction eFormAction) { final boolean bEdit = eFormAction.isEdit(); final Locale aDisplayLocale = aWPEC.getDisplayLocale(); final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().getCastedAttribute(ATTR_PROCESS); final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().getCastedAttribute(ATTR_ENDPOINT); final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr(); final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr(); final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr(); final SMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr(); final String sServiceGroupID = bEdit ? aSelectedObject.getServiceGroupID() : aWPEC.getAttributeAsString(FIELD_SERVICE_GROUP_ID); ISMPServiceGroup aServiceGroup = null; final String sDocTypeIDScheme = bEdit ? aSelectedObject.getDocumentTypeIdentifier().getScheme() : aWPEC.getAttributeAsString(FIELD_DOCTYPE_ID_SCHEME); final String sDocTypeIDValue = bEdit ? aSelectedObject.getDocumentTypeIdentifier().getValue() : aWPEC.getAttributeAsString(FIELD_DOCTYPE_ID_VALUE); IPeppolDocumentTypeIdentifier aDocTypeID = null; final String sProcessIDScheme = bEdit ? aSelectedProcess.getProcessIdentifier().getScheme() : aWPEC.getAttributeAsString(FIELD_PROCESS_ID_SCHEME); final String sProcessIDValue = bEdit ? aSelectedProcess.getProcessIdentifier().getValue() : aWPEC.getAttributeAsString(FIELD_PROCESS_ID_VALUE); IPeppolProcessIdentifier aProcessID = null; final String sTransportProfileID = bEdit ? aSelectedEndpoint.getTransportProfile() : aWPEC.getAttributeAsString(FIELD_TRANSPORT_PROFILE); final ISMPTransportProfile aTransportProfile = aTransportProfileMgr .getSMPTransportProfileOfID(sTransportProfileID); final String sEndpointReference = aWPEC.getAttributeAsString(FIELD_ENDPOINT_REFERENCE); final boolean bRequireBusinessLevelSignature = aWPEC .getAttributeAsBoolean(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE); final String sMinimumAuthenticationLevel = aWPEC.getAttributeAsString(FIELD_MINIMUM_AUTHENTICATION_LEVEL); final String sNotBefore = aWPEC.getAttributeAsString(FIELD_NOT_BEFORE); final LocalDate aNotBeforeDate = PDTFromString.getLocalDateFromString(sNotBefore, aDisplayLocale); final String sNotAfter = aWPEC.getAttributeAsString(FIELD_NOT_AFTER); final LocalDate aNotAfterDate = PDTFromString.getLocalDateFromString(sNotAfter, aDisplayLocale); final String sCertificate = aWPEC.getAttributeAsString(FIELD_CERTIFICATE); final String sServiceDescription = aWPEC.getAttributeAsString(FIELD_SERVICE_DESCRIPTION); final String sTechnicalContact = aWPEC.getAttributeAsString(FIELD_TECHNICAL_CONTACT); final String sTechnicalInformation = aWPEC.getAttributeAsString(FIELD_TECHNICAL_INFORMATION); final String sExtension = aWPEC.getAttributeAsString(FIELD_EXTENSION); // validations if (StringHelper.isEmpty(sServiceGroupID)) aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "A service group must be selected!"); else {/*w w w. j a v a 2s . co m*/ aServiceGroup = aServiceGroupManager .getSMPServiceGroupOfID(SimpleParticipantIdentifier.createFromURIPartOrNull(sServiceGroupID)); if (aServiceGroup == null) aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "The provided service group does not exist!"); } if (StringHelper.isEmpty(sDocTypeIDScheme)) aFormErrors.addFieldError(FIELD_DOCTYPE_ID_SCHEME, "Document type ID scheme must not be empty!"); else if (StringHelper.isEmpty(sDocTypeIDValue)) aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "Document type ID value must not be empty!"); else { aDocTypeID = SimpleDocumentTypeIdentifier.createFromURIPartOrNull( sDocTypeIDScheme + CIdentifier.URL_SCHEME_VALUE_SEPARATOR + sDocTypeIDValue); if (aDocTypeID == null) aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "The provided document type ID has an invalid syntax!"); else { if (aServiceGroup != null) if (aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID) != null) aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "At least one redirect is registered for this document type. Delete the redirect before you can create an endpoint."); } } if (StringHelper.isEmpty(sProcessIDScheme)) aFormErrors.addFieldError(FIELD_PROCESS_ID_SCHEME, "Process ID scheme must not be empty!"); else if (StringHelper.isEmpty(sProcessIDValue)) aFormErrors.addFieldError(FIELD_PROCESS_ID_SCHEME, "Process ID value must not be empty!"); else { aProcessID = SimpleProcessIdentifier.createFromURIPartOrNull( sProcessIDScheme + CIdentifier.URL_SCHEME_VALUE_SEPARATOR + sProcessIDValue); if (aProcessID == null) aFormErrors.addFieldError(FIELD_PROCESS_ID_VALUE, "The provided process ID has an invalid syntax!"); } if (StringHelper.isEmpty(sTransportProfileID)) aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Transport Profile must not be empty!"); else if (aTransportProfile == null) aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Transport Profile of type '" + sTransportProfileID + "' does not exist!"); if (!bEdit && aServiceGroup != null && aDocTypeID != null && aProcessID != null && aTransportProfile != null && aServiceInfoMgr.findServiceInformation(aServiceGroup, aDocTypeID, aProcessID, aTransportProfile) != null) aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Another endpoint for the provided service group, document type, process and transport profile is already present."); if (StringHelper.isEmpty(sEndpointReference)) { if (false) aFormErrors.addFieldError(FIELD_ENDPOINT_REFERENCE, "Endpoint Reference must not be empty!"); } else if (URLHelper.getAsURL(sEndpointReference) == null) aFormErrors.addFieldError(FIELD_ENDPOINT_REFERENCE, "The Endpoint Reference is not a valid URL!"); if (aNotBeforeDate != null && aNotAfterDate != null) if (aNotBeforeDate.isAfter(aNotAfterDate)) aFormErrors.addFieldError(FIELD_NOT_BEFORE, "Not Before Date must not be after Not After Date!"); if (StringHelper.isEmpty(sCertificate)) aFormErrors.addFieldError(FIELD_CERTIFICATE, "Certificate must not be empty!"); else { X509Certificate aCert = null; try { aCert = CertificateHelper.convertStringToCertficate(sCertificate); } catch (final CertificateException ex) { // Fall through } if (aCert == null) aFormErrors.addFieldError(FIELD_CERTIFICATE, "The provided certificate string is not a valid X509 certificate!"); } if (StringHelper.isEmpty(sServiceDescription)) aFormErrors.addFieldError(FIELD_SERVICE_DESCRIPTION, "Service Description must not be empty!"); if (StringHelper.isEmpty(sTechnicalContact)) aFormErrors.addFieldError(FIELD_TECHNICAL_CONTACT, "Technical Contact must not be empty!"); if (StringHelper.hasText(sExtension)) { final IMicroDocument aDoc = MicroReader.readMicroXML(sExtension); if (aDoc == null) aFormErrors.addFieldError(FIELD_EXTENSION, "The extension must be XML content."); } if (aFormErrors.isEmpty()) { ISMPServiceInformation aServiceInfo = aServiceInfoMgr .getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID); if (aServiceInfo == null) aServiceInfo = new SMPServiceInformation(aServiceGroup, aDocTypeID, null, null); ISMPProcess aProcess = aServiceInfo.getProcessOfID(aProcessID); if (aProcess == null) { aProcess = new SMPProcess(aProcessID, null, null); aServiceInfo.addProcess((SMPProcess) aProcess); } aProcess.setEndpoint(new SMPEndpoint(sTransportProfileID, sEndpointReference, bRequireBusinessLevelSignature, sMinimumAuthenticationLevel, aNotBeforeDate == null ? null : aNotBeforeDate.toLocalDateTime(CPDT.NULL_LOCAL_TIME), aNotAfterDate == null ? null : aNotAfterDate.toLocalDateTime(CPDT.NULL_LOCAL_TIME), sCertificate, sServiceDescription, sTechnicalContact, sTechnicalInformation, sExtension)); aServiceInfoMgr.mergeSMPServiceInformation(aServiceInfo); if (bEdit) { aWPEC.postRedirectGet( new BootstrapSuccessBox().addChild("Successfully edited the endpoint for service group '" + aServiceGroup.getParticpantIdentifier().getURIEncoded() + "'.")); } else { aWPEC.postRedirectGet( new BootstrapSuccessBox().addChild("Successfully created a new endpoint for service group '" + aServiceGroup.getParticpantIdentifier().getURIEncoded() + "'.")); } } }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
@NonNull private LocalDateTime getTimeCal(@Nullable LocalDate date, int time) { if (date == null) { date = LocalDate.now();//from www . java 2 s.com } if ((time < 0) || (time > 5)) { while (time >= 6) { date = date.plusDays(1); time -= 6; } while (time <= -1) { date = date.minusDays(1); time += 6; } } LocalDateTime timeCal = date.toLocalDateTime(new LocalTime(getTime(date, time))); int h = timeCal.getHourOfDay(); if ((time >= 3) && (h < 5)) { timeCal = timeCal.plusDays(1); } return timeCal; }
From source file:com.prayer.vakit.times.Times.java
License:Apache License
public LocalDateTime getTimeCal(LocalDate date, int time) { if (date == null) { date = LocalDate.now();/*from ww w . ja v a 2s .c o m*/ } if ((time < 0) || (time > 5)) { while (time >= 6) { date = date.plusDays(1); time -= 6; } while (time <= -1) { date = date.minusDays(1); time += 6; } } LocalDateTime timeCal = date.toLocalDateTime(new LocalTime(getTime(date, time))); int h = timeCal.getHourOfDay(); if ((time >= 3) && (h < 5)) { timeCal = timeCal.plusDays(1); } return timeCal; }