Example usage for org.joda.time LocalTime fromDateFields

List of usage examples for org.joda.time LocalTime fromDateFields

Introduction

In this page you can find the example usage for org.joda.time LocalTime fromDateFields.

Prototype

@SuppressWarnings("deprecation")
public static LocalTime fromDateFields(Date date) 

Source Link

Document

Constructs a LocalTime from a java.util.Date using exactly the same field values.

Usage

From source file:at.struct.wasbug21.converter.JodaTimeValueHandler.java

License:Apache License

@Override
public Object toObjectValue(ValueMapping vm, Object val) {
    if (vm.getType() == LocalTime.class) {
        return LocalTime.fromDateFields((Date) val);
    } else if (vm.getType() == LocalDate.class) {
        return LocalDate.fromDateFields((Date) val);
    } else if (vm.getType() == LocalDateTime.class) {
        return LocalDateTime.fromCalendarFields((Calendar) val);
    }/*from   w ww.  jav a2s  .c  o m*/

    throw new IllegalStateException(
            "only LocalTime, LocalDate and LocalDateTime can be handled with this ValueHandler");
}

From source file:br.com.tecsinapse.exporter.converter.LocalTimeTableCellConverter.java

License:LGPL

@Override
public LocalTime apply(Date input) {
    return LocalTime.fromDateFields(input);
}

From source file:eafit.cdei.util.IntervalGenerator.java

public static List<Interval> getIntervals(List<String> days, Time startTime, Time stopTime) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("YY-MM-DDH:mm:ss");

    List<Interval> tmpMeetTimeIntervals = new ArrayList<Interval>();
    LocalDate mondayDate = LocalDate.parse("2014-10-20");
    for (int x = 0; x <= 5; x++) {
        LocalDate tmpStartDate = mondayDate.plusDays(x);
        String tmpDay = tmpStartDate.toString("EEEE");
        if (days.contains(tmpDay)) {
            DateTime tmpStartDateTime = DateTime.parse(
                    tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(startTime).toString("H:mm:ss"),
                    fmt);//from  w w w  .  ja v a  2 s .c om
            DateTime tmpStopDateTime = DateTime.parse(
                    tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(stopTime).toString("H:mm:ss"),
                    fmt);
            tmpMeetTimeIntervals.add(new Interval(tmpStartDateTime, tmpStopDateTime));
        }
    }

    return tmpMeetTimeIntervals;
}

From source file:javaapplication5.ExibeLembrete.java

@Override
public void run() {
    try {//from w w w .j a  v  a  2  s  . co m
        int timeCounter = configs.getMinLembrete();
        while (true) {
            Date dt = new Date();
            LocalTime currentHour = LocalTime.fromDateFields(new Date());
            if (times != null) {
                for (LocalTime time : times) {
                    if (time != null) {
                        LocalTime diference = NewJFrame.decreaseTime(time, currentHour.getHourOfDay(),
                                currentHour.getMinuteOfHour());
                        if ((diference.getHourOfDay() == 0)
                                && (diference.getMinuteOfHour() <= configs.getMinLembrete())) {
                            if (traymanager != null) {
                                //                                boolean cont = false;
                                //                                if (timeCounter >= 1) {
                                //                                    cont = true;
                                //                                } else if (timeCounter >= 5) {
                                //                                    cont = true;
                                //                                }
                                if (timeCounter >= configs.getMinLembrete()) {
                                    JOptionPane.showMessageDialog(null, "Falta " + diference.toString("mm")
                                            + " min. para registrar o ponto!");
                                }
                                traymanager.displayMessage(
                                        "Falta " + diference.toString("mm") + " min. para registrar o ponto!");
                                timeCounter = 0;
                            }
                        }
                    }
                }
            }
            timeCounter++;
            Thread.sleep(1000 * 59);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.apache.sqoop.connector.hbase.HbaseExtractor.java

License:Apache License

@Override
public void extract(ExtractorContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig,
        GenericJdbcPartition partition) {
    HbaseExecutor executor = new HbaseExecutor(linkConfig.linkConfig);

    String query = context.getString(HbaseConnectorConstants.CONNECTOR_JDBC_FROM_DATA_SQL);
    String conditions = partition.getConditions();
    query = query.replace(HbaseConnectorConstants.SQL_CONDITIONS_TOKEN, conditions);
    LOG.info("Using query: " + query);

    rowsRead = 0;//from w  w w. j  av a 2s.  c  om
    ResultSet resultSet = executor.executeQuery(query);

    Schema schema = context.getSchema();
    Column[] schemaColumns = schema.getColumnsArray();
    try {
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
        if (schemaColumns.length != columnCount) {
            throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0021,
                    schemaColumns.length + ":" + columnCount);
        }
        while (resultSet.next()) {
            Object[] array = new Object[columnCount];
            for (int i = 0; i < columnCount; i++) {
                if (resultSet.getObject(i + 1) == null) {
                    array[i] = null;
                    continue;
                }
                // check type of the column
                Column schemaColumn = schemaColumns[i];
                switch (schemaColumn.getType()) {
                case DATE:
                    // convert the sql date to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalDate.fromDateFields((java.sql.Date) resultSet.getObject(i + 1));
                    break;
                case DATE_TIME:
                    // convert the sql date time to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalDateTime.fromDateFields((java.sql.Timestamp) resultSet.getObject(i + 1));
                    break;
                case TIME:
                    // convert the sql time to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalTime.fromDateFields((java.sql.Time) resultSet.getObject(i + 1));
                    break;
                default:
                    //for anything else
                    array[i] = resultSet.getObject(i + 1);

                }
            }
            context.getDataWriter().writeArrayRecord(array);
            rowsRead++;
        }
    } catch (SQLException e) {
        throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e);

    } finally {
        executor.close();
    }
}

From source file:org.apache.sqoop.connector.jdbc.GenericJdbcExtractor.java

License:Apache License

@Override
public void extract(ExtractorContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig,
        GenericJdbcPartition partition) {
    GenericJdbcExecutor executor = new GenericJdbcExecutor(linkConfig.linkConfig);

    String query = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_FROM_DATA_SQL);
    String conditions = partition.getConditions();
    query = query.replace(GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN, conditions);
    LOG.info("Using query: " + query);

    rowsRead = 0;//from  w  w w. ja  va  2s.  co m
    ResultSet resultSet = executor.executeQuery(query);

    Schema schema = context.getSchema();
    Column[] schemaColumns = schema.getColumnsArray();
    try {
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
        if (schemaColumns.length != columnCount) {
            throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0021,
                    schemaColumns.length + ":" + columnCount);
        }
        while (resultSet.next()) {
            Object[] array = new Object[columnCount];
            for (int i = 0; i < columnCount; i++) {
                if (resultSet.getObject(i + 1) == null) {
                    array[i] = null;
                    continue;
                }
                // check type of the column
                Column schemaColumn = schemaColumns[i];
                switch (schemaColumn.getType()) {
                case DATE:
                    // convert the sql date to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalDate.fromDateFields((java.sql.Date) resultSet.getObject(i + 1));
                    break;
                case DATE_TIME:
                    // convert the sql date time to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalDateTime.fromDateFields((java.sql.Timestamp) resultSet.getObject(i + 1));
                    break;
                case TIME:
                    // convert the sql time to JODA time as prescribed the Sqoop IDF spec
                    array[i] = LocalTime.fromDateFields((java.sql.Time) resultSet.getObject(i + 1));
                    break;
                default:
                    //for anything else
                    array[i] = resultSet.getObject(i + 1);

                }
            }
            context.getDataWriter().writeArrayRecord(array);
            rowsRead++;
        }
    } catch (SQLException e) {
        throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0004, e);

    } finally {
        executor.close();
    }
}

From source file:org.kuali.kpme.core.calendar.CalendarBo.java

License:Educational Community License

public LocalTime getFlsaBeginLocalTime() {
    return getFlsaBeginTime() == null ? null : LocalTime.fromDateFields(getFlsaBeginTime());
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBeginPeriodDate(Date beginPeriodDate) {
    LocalDate localDate = beginPeriodDate != null ? LocalDate.fromDateFields(beginPeriodDate) : null;
    LocalTime localTime = beginPeriodDateTime != null ? LocalTime.fromDateFields(beginPeriodDateTime)
            : LocalTime.MIDNIGHT;
    beginPeriodDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBeginPeriodTime(Time beginPeriodTime) {
    LocalDate localDate = beginPeriodDateTime != null ? LocalDate.fromDateFields(beginPeriodDateTime)
            : LocalDate.now();/*w  w  w .j  a  v  a  2 s .com*/
    LocalTime localTime = beginPeriodTime != null ? LocalTime.fromDateFields(beginPeriodTime) : null;
    beginPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setEndPeriodDate(Date endPeriodDate) {
    LocalDate localDate = endPeriodDate != null ? LocalDate.fromDateFields(endPeriodDate) : null;
    LocalTime localTime = endPeriodDateTime != null ? LocalTime.fromDateFields(endPeriodDateTime)
            : LocalTime.MIDNIGHT;
    endPeriodDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
}