Example usage for org.joda.time DateTime toLocalTime

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

Introduction

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

Prototype

public LocalTime toLocalTime() 

Source Link

Document

Converts this object to a LocalTime with the same time and chronology.

Usage

From source file:au.com.scds.chats.dom.call.CalendarDayCallSchedule.java

License:Apache License

@Action()
@ActionLayout()/* www.j  a  v  a 2  s. co m*/
@MemberOrder(name = "scheduledCalls", sequence = "1")
public CalendarDayCallSchedule addNewCall(
        @Parameter(optionality = Optionality.MANDATORY) final Participant participant,
        @Parameter(optionality = Optionality.MANDATORY) final DateTime dateTime) throws Exception {
    ScheduledCall call = scheduleCall(participant, dateTime.toLocalTime());
    //call.setParticipant(participant);
    return this;
}

From source file:au.com.scds.chats.dom.call.Calls.java

License:Apache License

@Programmatic
public ScheduledCall createScheduledCall(final Volunteer volunteer, final Participant participant,
        final DateTime dateTime) throws Exception {
    // see if there is a Schedule for this Volunteer on this day
    if (dateTime == null) {
        throw new IllegalArgumentException("dateTime is a mandatory argument");
    }// w w w.  ja  va  2s.  c o m
    CalendarDayCallSchedule sched = null;
    if (volunteer != null) {
        List<CalendarDayCallSchedule> schedules = listDailyCallSchedulesForVolunteer(volunteer);
        for (CalendarDayCallSchedule s : schedules) {
            if (s.getCalendarDate().equals(dateTime.toLocalDate())) {
                sched = s;
                break;
            }
        }
    } else {
        throw new IllegalArgumentException("volunteer is a mandatory argument");
    }
    if (sched == null) {
        sched = createCalendarDayCallSchedule(dateTime.toLocalDate(), volunteer);
    }
    // add a new call
    // TODO should an exception be trapped here?
    ScheduledCall call = sched.scheduleCall(participant, dateTime.toLocalTime());
    // call.setParticipant(participant);
    call.setRegion(participant.getRegion());
    call.setIsCompleted(false);
    return call;
}

From source file:br.com.caelum.vraptor.converter.jodatime.LocalTimeConverter.java

License:Open Source License

public LocalTime convert(String value, Class<? extends LocalTime> type, ResourceBundle bundle) {
    try {/*from   w  w w .j  av a 2  s .  c  om*/
        DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortTime());
        if (out == null) {
            return null;
        }

        return out.toLocalTime();
    } catch (Exception e) {
        throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_time"), value));
    }
}

From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemDateTime.java

License:Open Source License

public CosemDateTime(final DateTime dateTime) {
    this(dateTime.toLocalDate(), dateTime.toLocalTime(), determineDeviation(dateTime),
            determineClockStatus(dateTime));
}

From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemDateTimeDto.java

License:Open Source License

public CosemDateTimeDto(final DateTime dateTime) {
    this(dateTime.toLocalDate(), dateTime.toLocalTime(), determineDeviation(dateTime),
            determineClockStatus(dateTime));
}

From source file:com.axelor.data.adapter.JodaAdapter.java

License:Open Source License

@Override
public Object adapt(Object value, Map<String, Object> context) {

    if (value == null || !(value instanceof String)) {
        return value;
    }/*from w  w  w  .  j  a  v  a  2 s .  com*/

    String format = this.get("format", DEFAULT_FORMAT);

    DateTimeFormatter fmt = DateTimeFormat.forPattern(format);
    DateTime dt;
    try {
        dt = fmt.parseDateTime((String) value);
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid value: " + value, e);
    }

    String type = this.get("type", null);

    if ("LocalDate".equals(type)) {
        return dt.toLocalDate();
    }
    if ("LocalTime".equals(type)) {
        return dt.toLocalTime();
    }
    if ("LocalDateTime".equals(type)) {
        return dt.toLocalDateTime();
    }
    return dt;
}

From source file:com.helger.datetime.format.PDTFromString.java

License:Apache License

@Nullable
public static LocalTime getLocalTimeFromString(@Nullable final String sValue,
        @Nonnull final DateTimeFormatter aDF) {
    final DateTime aDT = getDateTimeFromString(sValue, aDF);
    return aDT == null ? null : aDT.toLocalTime();
}

From source file:com.helger.datetime.format.PDTFromString.java

License:Apache License

@Nullable
public static LocalTime getLocalTimeFromString(@Nullable final String sValue, @Nonnull final String sPattern) {
    final DateTime aDT = getDateTimeFromString(sValue, sPattern);
    return aDT == null ? null : aDT.toLocalTime();
}

From source file:com.helger.datetime.PDTFactory.java

License:Apache License

@Nonnull
public static LocalTime createLocalTime(@Nonnull final DateTime aDateTime) {
    return aDateTime.toLocalTime();
}

From source file:com.helger.maven.buildinfo.GenerateBuildInfoMojo.java

License:Apache License

private Map<String, String> _determineBuildInfoProperties() {
    // Get the current time, using the time zone specified in the settings
    final DateTime aDT = PDTFactory.getCurrentDateTime();

    // Build the default properties
    final Map<String, String> aProps = new LinkedHashMap<String, String>();
    // Version 1: initial
    // Version 2: added dependency information; added per build plugin the key
    // property/* w w  w .  java  2s .  c om*/
    aProps.put("buildinfo.version", "2");

    // Project information
    aProps.put("project.groupid", project.getGroupId());
    aProps.put("project.artifactid", project.getArtifactId());
    aProps.put("project.version", project.getVersion());
    aProps.put("project.name", project.getName());
    aProps.put("project.packaging", project.getPackaging());

    // Parent project information (if available)
    final MavenProject aParentProject = project.getParent();
    if (aParentProject != null) {
        aProps.put("parentproject.groupid", aParentProject.getGroupId());
        aProps.put("parentproject.artifactid", aParentProject.getArtifactId());
        aProps.put("parentproject.version", aParentProject.getVersion());
        aProps.put("parentproject.name", aParentProject.getName());
    }

    // All reactor projects (nested projects)
    // Don't emit this, if this is "1" as than only the current project would be
    // listed
    if (reactorProjects != null && reactorProjects.size() != 1) {
        final String sPrefix = "reactorproject.";

        // The number of reactor projects
        aProps.put(sPrefix + "count", Integer.toString(reactorProjects.size()));

        // Show details of all reactor projects, index starting at 0
        int nIndex = 0;
        for (final MavenProject aReactorProject : reactorProjects) {
            aProps.put(sPrefix + nIndex + ".groupid", aReactorProject.getGroupId());
            aProps.put(sPrefix + nIndex + ".artifactid", aReactorProject.getArtifactId());
            aProps.put(sPrefix + nIndex + ".version", aReactorProject.getVersion());
            aProps.put(sPrefix + nIndex + ".name", aReactorProject.getName());
            ++nIndex;
        }
    }

    // Build Plugins
    final List<?> aBuildPlugins = project.getBuildPlugins();
    if (aBuildPlugins != null) {
        final String sPrefix = "build.plugin.";
        // The number of build plugins
        aProps.put(sPrefix + "count", Integer.toString(aBuildPlugins.size()));

        // Show details of all plugins, index starting at 0
        int nIndex = 0;
        for (final Object aObj : aBuildPlugins) {
            final Plugin aPlugin = (Plugin) aObj;
            aProps.put(sPrefix + nIndex + ".groupid", aPlugin.getGroupId());
            aProps.put(sPrefix + nIndex + ".artifactid", aPlugin.getArtifactId());
            aProps.put(sPrefix + nIndex + ".version", aPlugin.getVersion());
            final Object aConfiguration = aPlugin.getConfiguration();
            if (aConfiguration != null) {
                // Will emit an XML structure!
                aProps.put(sPrefix + nIndex + ".configuration", aConfiguration.toString());
            }
            aProps.put(sPrefix + nIndex + ".key", aPlugin.getKey());
            ++nIndex;
        }
    }

    // Build dependencies
    final List<?> aDependencies = project.getDependencies();
    if (aDependencies != null) {
        final String sDepPrefix = "dependency.";
        // The number of build plugins
        aProps.put(sDepPrefix + "count", Integer.toString(aDependencies.size()));

        // Show details of all dependencies, index starting at 0
        int nDepIndex = 0;
        for (final Object aDepObj : aDependencies) {
            final Dependency aDependency = (Dependency) aDepObj;
            aProps.put(sDepPrefix + nDepIndex + ".groupid", aDependency.getGroupId());
            aProps.put(sDepPrefix + nDepIndex + ".artifactid", aDependency.getArtifactId());
            aProps.put(sDepPrefix + nDepIndex + ".version", aDependency.getVersion());
            aProps.put(sDepPrefix + nDepIndex + ".type", aDependency.getType());
            if (aDependency.getClassifier() != null)
                aProps.put(sDepPrefix + nDepIndex + ".classifier", aDependency.getClassifier());
            aProps.put(sDepPrefix + nDepIndex + ".scope", aDependency.getScope());
            if (aDependency.getSystemPath() != null)
                aProps.put(sDepPrefix + nDepIndex + ".systempath", aDependency.getSystemPath());
            aProps.put(sDepPrefix + nDepIndex + ".optional", Boolean.toString(aDependency.isOptional()));
            aProps.put(sDepPrefix + nDepIndex + ".managementkey", aDependency.getManagementKey());

            // Add all exclusions of the current dependency
            final List<?> aExclusions = aDependency.getExclusions();
            if (aExclusions != null) {
                final String sExclusionPrefix = sDepPrefix + nDepIndex + ".exclusion.";
                // The number of build plugins
                aProps.put(sExclusionPrefix + "count", Integer.toString(aExclusions.size()));

                // Show details of all dependencies, index starting at 0
                int nExclusionIndex = 0;
                for (final Object aExclusionObj : aExclusions) {
                    final Exclusion aExclusion = (Exclusion) aExclusionObj;
                    aProps.put(sExclusionPrefix + nExclusionIndex + ".groupid", aExclusion.getGroupId());
                    aProps.put(sExclusionPrefix + nExclusionIndex + ".artifactid", aExclusion.getArtifactId());
                    ++nExclusionIndex;
                }
            }

            ++nDepIndex;
        }
    }

    // Build date and time
    aProps.put("build.datetime", aDT.toString());
    aProps.put("build.datetime.millis", Long.toString(aDT.getMillis()));
    aProps.put("build.datetime.date", aDT.toLocalDate().toString());
    aProps.put("build.datetime.time", aDT.toLocalTime().toString());
    aProps.put("build.datetime.timezone", aDT.getZone().getID());
    final int nOfsMilliSecs = aDT.getZone().getOffset(aDT);
    aProps.put("build.datetime.timezone.offsethours",
            Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_HOUR));
    aProps.put("build.datetime.timezone.offsetmins",
            Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_MINUTE));
    aProps.put("build.datetime.timezone.offsetsecs",
            Long.toString(nOfsMilliSecs / CGlobal.MILLISECONDS_PER_SECOND));
    aProps.put("build.datetime.timezone.offsetmillisecs", Integer.toString(nOfsMilliSecs));

    // Emit system properties?
    if (withAllSystemProperties || CollectionHelper.isNotEmpty(selectedSystemProperties))
        for (final Map.Entry<String, String> aEntry : CollectionHelper
                .getSortedByKey(SystemProperties.getAllProperties()).entrySet()) {
            final String sName = aEntry.getKey();
            if (withAllSystemProperties || _matches(selectedSystemProperties, sName))
                if (!_matches(ignoredSystemProperties, sName))
                    aProps.put("systemproperty." + sName, aEntry.getValue());
        }

    // Emit environment variable?
    if (withAllEnvVars || CollectionHelper.isNotEmpty(selectedEnvVars))
        for (final Map.Entry<String, String> aEntry : CollectionHelper.getSortedByKey(System.getenv())
                .entrySet()) {
            final String sName = aEntry.getKey();
            if (withAllEnvVars || _matches(selectedEnvVars, sName))
                if (!_matches(ignoredEnvVars, sName))
                    aProps.put("envvar." + sName, aEntry.getValue());
        }

    return aProps;
}