List of usage examples for org.joda.time DateTime getSecondOfMinute
public int getSecondOfMinute()
From source file:com.foundationdb.server.types.mcompat.mtypes.MDateAndTime.java
License:Open Source License
/** Convert {@code millis} to a DateTime and {@link #encodeTime(long, long, long, TExecutionContext)}. */ public static int encodeTime(long millis, String tz) { DateTime dt = new DateTime(millis, DateTimeZone.forID(tz)); return encodeTime(dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute(), null); }
From source file:com.foundationdb.server.types.mcompat.mtypes.MDateAndTime.java
License:Open Source License
/** Decode {@code encodedTimestamp} using the {@code tz} timezone. */ public static long[] decodeTimestamp(long encodedTimestamp, String tz) { DateTime dt = new DateTime(encodedTimestamp * 1000L, DateTimeZone.forID(tz)); return new long[] { dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute() }; }
From source file:com.github.autermann.matlab.value.MatlabDateTime.java
License:Open Source License
public double[] toArray() { DateTime utc = time.toDateTime(DateTimeZone.UTC); return new double[] { (double) utc.getYear(), (double) utc.getMonthOfYear(), (double) utc.getDayOfMonth(), (double) utc.getHourOfDay(), (double) utc.getMinuteOfHour(), (double) utc.getSecondOfMinute() + (double) utc.getMillisOfSecond() / 1000, }; }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime thirtySeconds(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); if (dateTime.getSecondOfMinute() < 30) { return dateTime.withSecondOfMinute(0); } else {// www . j av a2 s .c o m return dateTime.withSecondOfMinute(30); } }
From source file:com.github.markserrano.jsonquery.jpa.util.DateTimeUtil.java
License:Apache License
public static Map<String, DateTime> getYesterdaySpan() { DateTime now = new DateTime(); DateTime from = now.minusDays(1).minusHours(now.getHourOfDay()).minusMinutes(now.getMinuteOfHour()) .minusSeconds(now.getSecondOfMinute()).minusMillis(now.getMillisOfSecond()); DateTime to = from.plusHours(23).plusMinutes(59).plusSeconds(59); Map<String, DateTime> map = new HashMap<String, DateTime>(); map.put("from", from); map.put("to", to); return map;/*from ww w .java 2s . c o m*/ }
From source file:com.google.cloud.dataflow.sdk.util.TimeUtil.java
License:Apache License
/** * Converts a {@link ReadableInstant} into a Dateflow API time value. *///from w w w. j a v a2s . c o m public static String toCloudTime(ReadableInstant instant) { // Note that since Joda objects use millisecond resolution, we always // produce either no fractional seconds or fractional seconds with // millisecond resolution. // Translate the ReadableInstant to a DateTime with ISOChronology. DateTime time = new DateTime(instant); int millis = time.getMillisOfSecond(); if (millis == 0) { return String.format("%04d-%02d-%02dT%02d:%02d:%02dZ", time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute()); } else { return String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), millis); } }
From source file:com.google.jenkins.plugins.cloudbackup.backup.BackupProcedure.java
License:Open Source License
private static String calculateBackupName(DateTime backupTime) { return String.format("backup-%d%02d%02d%02d%02d%02d", backupTime.getYear(), backupTime.getMonthOfYear(), backupTime.getDayOfMonth(), backupTime.getHourOfDay(), backupTime.getMinuteOfHour(), backupTime.getSecondOfMinute()); }
From source file:com.gst.infrastructure.reportmailingjob.service.ReportMailingJobWritePlatformServiceImpl.java
License:Apache License
/** * create the next recurring DateTime from recurrence pattern, start DateTime and current DateTime * /*from w ww . ja va2s. com*/ * @param recurrencePattern * @param startDateTime * @return DateTime object */ private DateTime createNextRecurringDateTime(final String recurrencePattern, final DateTime startDateTime) { DateTime nextRecurringDateTime = null; // the recurrence pattern/rule cannot be empty if (StringUtils.isNotBlank(recurrencePattern) && startDateTime != null) { final LocalDate nextDayLocalDate = startDateTime.plus(1).toLocalDate(); final LocalDate nextRecurringLocalDate = CalendarUtils.getNextRecurringDate(recurrencePattern, startDateTime.toLocalDate(), nextDayLocalDate); final String nextDateTimeString = nextRecurringLocalDate + " " + startDateTime.getHourOfDay() + ":" + startDateTime.getMinuteOfHour() + ":" + startDateTime.getSecondOfMinute(); final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(DATETIME_FORMAT); nextRecurringDateTime = DateTime.parse(nextDateTimeString, dateTimeFormatter); } return nextRecurringDateTime; }
From source file:com.hangum.tadpold.commons.libs.core.sqls.ParameterUtils.java
License:Open Source License
/** * original code is http://www.gotoquiz.com/web-coding/programming/java-programming/log-sql-statements-with-parameter-values-filled-in-spring-jdbc/ * // ww w .ja v a 2 s . co m * @param statement * @param sqlArgs * @return */ public static String fillParameters(String statement, Object[] sqlArgs) { // initialize a StringBuilder with a guesstimated final length StringBuilder completedSqlBuilder = new StringBuilder(Math.round(statement.length() * 1.2f)); int index, // will hold the index of the next ? prevIndex = 0; // will hold the index of the previous ? + 1 // loop through each SQL argument for (Object arg : sqlArgs) { index = statement.indexOf("?", prevIndex); if (index == -1) break; // bail out if there's a mismatch in # of args vs. ?'s // append the chunk of SQL coming before this ? completedSqlBuilder.append(statement.substring(prevIndex, index)); if (arg == null) completedSqlBuilder.append("NULL"); else if (arg instanceof String) { // wrap the String in quotes and escape any quotes within completedSqlBuilder.append('\'').append(arg.toString().replace("'", "''")).append('\''); } else if (arg instanceof Date) { // convert it to a Joda DateTime DateTime dateTime = new DateTime((Date) arg); // test to see if it's a DATE or a TIMESTAMP if (dateTime.getHourOfDay() == LocalTime.MIDNIGHT.getHourOfDay() && dateTime.getMinuteOfHour() == LocalTime.MIDNIGHT.getMinuteOfHour() && dateTime.getSecondOfMinute() == LocalTime.MIDNIGHT.getSecondOfMinute()) { completedSqlBuilder.append("DATE '").append(DATE_FORMATTER.print(dateTime)).append('\''); } else { completedSqlBuilder.append("TIMESTAMP '").append(TIMESTAMP_FORMATTER.print(dateTime)) .append('\''); } } else completedSqlBuilder.append(arg.toString()); prevIndex = index + 1; } // add the rest of the SQL if any if (prevIndex != statement.length()) completedSqlBuilder.append(statement.substring(prevIndex)); return completedSqlBuilder.toString(); }
From source file:com.moss.joda.swing.JodaOptionPane.java
License:Open Source License
private static TimeOfDay parseTime(String text) { if (text == null || text.trim().length() == 0) { return null; } else {//w w w . j a va 2 s. c o m DateTime paddedTime = null; for (DateTimeFormatter format : timeFormats) { try { paddedTime = format.parseDateTime(text); } catch (IllegalArgumentException e) { // just means the text is no good. } } if (paddedTime == null) throw new RuntimeException("Unparsable time: " + text); return new TimeOfDay(paddedTime.getHourOfDay(), paddedTime.getMinuteOfHour(), paddedTime.getSecondOfMinute()); } }