List of usage examples for org.joda.time LocalDateTime getMillisOfSecond
public int getMillisOfSecond()
From source file:cherry.goods.util.JodaTimeUtil.java
License:Apache License
/** * @param ldtm ???{@link LocalDateTime}// w w w . j a va 2s. c om * @return ?????{@link Calendar}(?)???????? */ public static Calendar getCalendar(LocalDateTime ldtm) { Calendar cal = Calendar.getInstance(); cal.set(ldtm.getYear(), ldtm.getMonthOfYear() - 1, ldtm.getDayOfMonth(), ldtm.getHourOfDay(), ldtm.getMinuteOfHour(), ldtm.getSecondOfMinute()); cal.set(MILLISECOND, ldtm.getMillisOfSecond()); return cal; }
From source file:com.gs.fw.common.mithra.databasetype.SybaseIqNativeDatabaseType.java
License:Apache License
@Override public Timestamp getTimestampFromResultSet(ResultSet rs, int pos, TimeZone timeZone) throws SQLException { Timestamp localTs = rs.getTimestamp(pos); if (localTs == null) { return null; }//from w ww . j ava 2 s . c o m LocalDateTime ldt = new LocalDateTime(localTs.getTime()); Calendar utcCal = getCalendarInstance(); utcCal.set(Calendar.YEAR, ldt.getYear()); utcCal.set(Calendar.MONTH, ldt.getMonthOfYear() - 1); utcCal.set(Calendar.DAY_OF_MONTH, ldt.getDayOfMonth()); utcCal.set(Calendar.HOUR_OF_DAY, ldt.getHourOfDay()); utcCal.set(Calendar.MINUTE, ldt.getMinuteOfHour()); utcCal.set(Calendar.SECOND, ldt.getSecondOfMinute()); utcCal.set(Calendar.MILLISECOND, ldt.getMillisOfSecond()); Timestamp utcTs = new Timestamp(utcCal.getTimeInMillis()); return MithraTimestamp.zConvertTimeForReadingWithUtcCalendar(utcTs, timeZone); }
From source file:com.gs.fw.common.mithra.util.Time.java
License:Apache License
public static Time withSqlTime(java.sql.Time sqlTime) { if (sqlTime == null) return null; LocalDateTime localDateTime = new LocalDateTime(sqlTime.getTime()); return Time.withMillis(localDateTime.getHourOfDay(), localDateTime.getMinuteOfHour(), localDateTime.getSecondOfMinute(), localDateTime.getMillisOfSecond()); }
From source file:com.gst.infrastructure.dataqueries.service.GenericDataServiceImpl.java
License:Apache License
@Override public String generateJsonFromGenericResultsetData(final GenericResultsetData grs) { final StringBuffer writer = new StringBuffer(); writer.append("["); final List<ResultsetColumnHeaderData> columnHeaders = grs.getColumnHeaders(); final List<ResultsetRowData> data = grs.getData(); List<String> row; Integer rSize;/*from ww w . java 2 s . c om*/ final String doubleQuote = "\""; final String slashDoubleQuote = "\\\""; String currColType; String currVal; for (int i = 0; i < data.size(); i++) { writer.append("\n{"); row = data.get(i).getRow(); rSize = row.size(); for (int j = 0; j < rSize; j++) { writer.append(doubleQuote + columnHeaders.get(j).getColumnName() + doubleQuote + ": "); currColType = columnHeaders.get(j).getColumnDisplayType(); final String colType = columnHeaders.get(j).getColumnType(); if (currColType == null && colType.equalsIgnoreCase("INT")) { currColType = "INTEGER"; } if (currColType == null && colType.equalsIgnoreCase("VARCHAR")) { currColType = "VARCHAR"; } if (currColType == null && colType.equalsIgnoreCase("DATE")) { currColType = "DATE"; } currVal = row.get(j); if (currVal != null && currColType != null) { if (currColType.equals("DECIMAL") || currColType.equals("INTEGER")) { writer.append(currVal); } else { if (currColType.equals("DATE")) { final LocalDate localDate = new LocalDate(currVal); writer.append("[" + localDate.getYear() + ", " + localDate.getMonthOfYear() + ", " + localDate.getDayOfMonth() + "]"); } else if (currColType.equals("DATETIME")) { final LocalDateTime localDateTime = new LocalDateTime(currVal); writer.append("[" + localDateTime.getYear() + ", " + localDateTime.getMonthOfYear() + ", " + localDateTime.getDayOfMonth() + " " + localDateTime.getHourOfDay() + ", " + localDateTime.getMinuteOfHour() + ", " + localDateTime.getSecondOfMinute() + ", " + localDateTime.getMillisOfSecond() + "]"); } else { writer.append( doubleQuote + replace(currVal, doubleQuote, slashDoubleQuote) + doubleQuote); } } } else { writer.append("null"); } if (j < (rSize - 1)) { writer.append(",\n"); } } if (i < (data.size() - 1)) { writer.append("},"); } else { writer.append("}"); } } writer.append("\n]"); return writer.toString(); }
From source file:com.helger.datetime.xml.PDTXMLConverter.java
License:Apache License
/** * Get the passed object as {@link XMLGregorianCalendar} with date and time. * * @param aBase// w w w . java 2 s. com * The source object. May be <code>null</code>. * @return <code>null</code> if the parameter is <code>null</code>. */ @Nullable public static XMLGregorianCalendar getXMLCalendar(@Nullable final LocalDateTime aBase) { return aBase == null ? null : s_aDTFactory.newXMLGregorianCalendar(aBase.getYear(), aBase.getMonthOfYear(), aBase.getDayOfMonth(), aBase.getHourOfDay(), aBase.getMinuteOfHour(), aBase.getSecondOfMinute(), aBase.getMillisOfSecond(), DatatypeConstants.FIELD_UNDEFINED); }
From source file:de.jpaw.bonaparte.util.DayTime.java
License:Apache License
/** Converts the time portion of a LocalTime or localDateTime into a number in the format HHMMSSMMM. */ static public int timeAsInt(LocalDateTime when) { return when.getMillisOfSecond() + 1000 * when.getSecondOfMinute() + 100000 * when.getMinuteOfHour() + 10000000 * when.getHourOfDay(); }
From source file:org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateTimeXMLGregorianCalendarAdapter.java
License:Apache License
public static XMLGregorianCalendar print(final LocalDateTime dateTime) { if (dateTime == null) return null; final XMLGregorianCalendarImpl xgc = new XMLGregorianCalendarImpl(); xgc.setYear(dateTime.getYear());// w ww .j a va2 s .c om xgc.setMonth(dateTime.getMonthOfYear()); xgc.setDay(dateTime.getDayOfMonth()); xgc.setHour(dateTime.getHourOfDay()); xgc.setMinute(dateTime.getMinuteOfHour()); xgc.setSecond(dateTime.getSecondOfMinute()); xgc.setMillisecond(dateTime.getMillisOfSecond()); return xgc; }
From source file:org.apache.isis.schema.utils.jaxbadapters.XmlCalendarFactory.java
License:Apache License
public static XMLGregorianCalendar create(LocalDateTime localDateTime) { return localDateTime != null ? withTypeFactoryDo(dtf -> dtf.newXMLGregorianCalendar(localDateTime.getYear(), localDateTime.getMonthOfYear(), localDateTime.getDayOfMonth(), localDateTime.getHourOfDay(), localDateTime.getMinuteOfHour(), localDateTime.getSecondOfMinute(), localDateTime.getMillisOfSecond(), DatatypeConstants.FIELD_UNDEFINED)) : null; }
From source file:org.fixb.impl.NativeFixMessageBuilder.java
License:Apache License
@Override public FixMessageBuilder<String> setField(int tag, LocalDateTime value, boolean header) { final String pattern = (value.getMillisOfSecond() == 0) ? DATE_TIME : DATE_TIME_WITH_MILLIS; return setField(tag, value.toString(pattern), header); }
From source file:org.jadira.usertype.dateandtime.joda.AbstractMultiColumnDateTime.java
License:Apache License
@Override protected DateTime fromConvertedColumns(Object[] convertedColumns) { LocalDateTime datePart = (LocalDateTime) convertedColumns[0]; DateTimeZone offset = (DateTimeZone) convertedColumns[1]; final DateTime result; if (datePart == null) { result = null;/*from www . j a va2 s. co m*/ } else { result = new DateTime(datePart.getYear(), datePart.getMonthOfYear(), datePart.getDayOfMonth(), datePart.getHourOfDay(), datePart.getMinuteOfHour(), datePart.getSecondOfMinute(), datePart.getMillisOfSecond(), offset); } return result; }