Example usage for org.joda.time DateTime getMinuteOfHour

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

Introduction

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

Prototype

public int getMinuteOfHour() 

Source Link

Document

Get the minute of hour field value.

Usage

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 a  2 s  .c om
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.google.sampling.experiential.model.SignalSchedule.java

License:Open Source License

public String getHourOffsetAsTimeString(Long time) {
    DateTime endHour = new DateMidnight().toDateTime().plus(time);
    String endHourString = endHour.getHourOfDay() + ":" + pad(endHour.getMinuteOfHour());
    return endHourString;
}

From source file:com.google.sampling.experiential.model.SignalSchedule.java

License:Open Source License

public String getHourOffsetAsTimeString(SignalTime time) {
    DateTime endHour = new DateMidnight().toDateTime().plus(time.getFixedTimeMillisFromMidnight());
    String endHourString = endHour.getHourOfDay() + ":" + pad(endHour.getMinuteOfHour());
    return endHourString;
}

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 v a2 s . c  o m*/
 * @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/
 * //  w  w w.  ja  va2s  . c  o  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.jay.pea.mhealthapp2.model.Dose.java

License:Open Source License

public void setTakenTime(DateTime takenTime) {

    this.takenTime = new DateTime().withHourOfDay(takenTime.getHourOfDay())
            .withMinuteOfHour(takenTime.getMinuteOfHour());
    if (takenTime != new DateTime(0))
        this.doseTaken = true;
    else//  ww w . ja  va  2 s  .c  om
        this.doseTaken = false;
}

From source file:com.jive.myco.seyren.core.domain.Subscription.java

License:Apache License

private boolean isCorrectHourOfDay(DateTime time) {
    LocalTime alertTime = new LocalTime(time.getHourOfDay(), time.getMinuteOfHour());
    return alertTime.isAfter(getFromTime()) && alertTime.isBefore(getToTime());
}

From source file:com.kopysoft.chronos.activities.Editors.NewPunchActivity.java

License:Open Source License

@Override
public void onCreate(Bundle savedInstanceState) {
    if (enableLog)
        Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.punch_pair_editor);

    Spinner taskSpinnerIn = (Spinner) findViewById(R.id.taskSpinnerIn);
    Spinner taskSpinnerOut = (Spinner) findViewById(R.id.taskSpinnerOut);
    try {/*  w ww .j a  va 2 s.c  om*/
        ((TextView) findViewById(R.id.punchTitleText)).setText("In/Out Time");
    } catch (NullPointerException e) {
        Log.e(TAG, "Could not find punchTitleText");
    }

    if (savedInstanceState != null) {
        jobID = savedInstanceState.getLong("job");
        date = new DateTime(savedInstanceState.getLong("date"));
    } else {
        jobID = getIntent().getExtras().getLong("job");
        date = new DateTime(getIntent().getExtras().getLong("date"));
    }

    if (enableLog)
        Log.d(TAG, "JobID: " + jobID);
    if (enableLog)
        Log.d(TAG, "DateTime: " + date);

    Chronos chron = new Chronos(this);
    tasks = chron.getAllTasks();

    @SuppressWarnings("unchecked")
    ArrayAdapter spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, tasks);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    taskSpinnerIn.setAdapter(spinnerAdapter);
    taskSpinnerOut.setAdapter(spinnerAdapter);
    //end task

    //set for 24 or 12 hour time
    boolean twentyFourHourTime = DateFormat.is24HourFormat(this);
    TimePicker inTime = (TimePicker) findViewById(R.id.TimePicker1);
    inTime.setIs24HourView(twentyFourHourTime);
    TimePicker outTime = (TimePicker) findViewById(R.id.TimePicker2);
    outTime.setIs24HourView(twentyFourHourTime);

    DateTime now = new DateTime();

    if (enableLog)
        Log.d(TAG, "P1 Current Hour: " + now.getHourOfDay());
    if (enableLog)
        Log.d(TAG, "P1 Current Minute: " + now.getMinuteOfHour());

    inTime.setCurrentHour(now.getHourOfDay());
    inTime.setCurrentMinute(now.getMinuteOfHour());
    taskSpinnerIn.setSelection(0);

    findViewById(R.id.outLayout).setVisibility(View.GONE);

    //close chronos
    chron.close();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    //This is a workaround for http://b.android.com/15340 from http://stackoverflow.com/a/5852198/132047
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        BitmapDrawable bg = (BitmapDrawable) getResources().getDrawable(R.drawable.bg_striped);
        bg.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        getSupportActionBar().setBackgroundDrawable(bg);

        BitmapDrawable bgSplit = (BitmapDrawable) getResources().getDrawable(R.drawable.bg_striped_split_img);
        bgSplit.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        getSupportActionBar().setSplitBackgroundDrawable(bgSplit);
    }

}

From source file:com.marand.thinkmed.medications.administration.impl.AdministrationTaskCreatorImpl.java

License:Open Source License

private Integer getDoseDurationForDate(final Map<HourMinuteDto, Integer> durations, final DateTime date) {
    return Opt.of(durations.get(new HourMinuteDto(date.getHourOfDay(), date.getMinuteOfHour())))
            .orElseThrow(() -> new IllegalStateException("No matching date in durations map!"));
}