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:controllers.lib.Database.java

License:Open Source License

private static boolean executeCleanStatisticDay() throws Exception {
    // Early Date
    //Date checkDate = new Date(System.currentTimeMillis() - 25 * 3600 * 1000);
    DateTime checkDate = new DateTime();
    checkDate = checkDate.minusHours(23).minusMinutes(checkDate.getMinuteOfHour())
            .minusSeconds(checkDate.getSecondOfMinute());

    List<StatisticDay> statisticDayList = StatisticDay.find.all();
    Iterator<StatisticDay> statisticDayIterator = statisticDayList.iterator();
    while (statisticDayIterator.hasNext()) {
        StatisticDay statisticDay = statisticDayIterator.next();
        if (statisticDay.updateTime.isBefore(checkDate)) {
            statisticDay.delete();//from   w  w w . ja  v a  2s . c o m
        }
    }
    return true;
}

From source file:course_generator.dialogs.frmTrackSettings.java

License:Open Source License

public boolean showDialog(CgSettings settings, TrackData track) {
    this.settings = settings;
    this.track = track;
    this.timezone = track.TrackTimeZone;
    this.summertime = track.TrackUseSumerTime;

    // Set field// w ww  . j  av a 2s  .  co m
    tfTrackName.setText(this.track.CourseName);
    tfDescription.setText(this.track.Description);
    jMonthView.setSelectionDate(this.track.StartTime.toDate());
    spinStartTimeModel.setValue(this.track.StartTime.toDate());
    chkElevationEffect.setSelected(this.track.bElevEffect);
    chkNightEffect.setSelected(this.track.bNightCoeff);
    spinStartNightModel.setValue(this.track.StartNightTime.toDate());
    spinEndNightModel.setValue(this.track.EndNightTime.toDate());
    spinAscCoeff.setValue(this.track.NightCoeffAsc);
    spinDescCoeff.setValue(this.track.NightCoeffDesc);

    // End set field
    ok = false;

    //-- Update the display
    Refresh();

    //-- Show the dialog
    setVisible(true);

    if (ok) {
        // Copy fields
        track.CourseName = tfTrackName.getText();
        track.Description = tfDescription.getText();
        DateTime std = new DateTime(jMonthView.getSelectionDate());
        DateTime stt = new DateTime(spinStartTimeModel.getValue());
        std = std.withTime(stt.getHourOfDay(), stt.getMinuteOfHour(), 0, 0);
        track.StartTime = std;

        track.bElevEffect = chkElevationEffect.isSelected();
        track.bNightCoeff = chkNightEffect.isSelected();
        track.StartNightTime = new DateTime(spinStartNightModel.getValue());
        track.EndNightTime = new DateTime(spinEndNightModel.getValue());

        track.NightCoeffAsc = spinAscCoeff.getValueAsDouble();
        track.NightCoeffDesc = spinDescCoeff.getValueAsDouble();

        track.TrackTimeZone = this.timezone;
        track.TrackUseSumerTime = this.summertime;
    }
    return ok;
}

From source file:course_generator.utils.Utils.java

License:Open Source License

/**
 * Compare two DateTime/*from  w ww .j  ava 2 s .  co  m*/
 * 
 * @param t1
 *            First DateTime
 * @param t2
 *            Second DateTime
 * @return Return 0 if t1=t2 Return 1 if t1>t2 Return -1 if t1<t2
 */
public static int CompareHMS(DateTime t1, DateTime t2) {
    int h1, h2, m1, m2, s1, s2;

    h1 = t1.getHourOfDay();
    m1 = t1.getMinuteOfHour();
    s1 = t1.getSecondOfMinute();

    h2 = t2.getHourOfDay();
    m2 = t2.getMinuteOfHour();
    s2 = t2.getSecondOfMinute();

    if ((h1 == h2) && (m1 == m2) && (s1 == s2))
        return 0;
    if ((h1 > h2) || ((h1 == h2) && (m1 > m2)) || ((h1 == h2) && (m1 == m2) && (s1 > s2)))
        return 1;
    return -1;
}

From source file:cron.DefaultCronExpression.java

License:Open Source License

@Override
public boolean matches(DateTime t) {
    return second.contains(t.getSecondOfMinute()) && minute.contains(t.getMinuteOfHour())
            && hour.contains(t.getHourOfDay()) && month.contains(t.getMonthOfYear())
            && year.contains(t.getYear()) && dayOfWeek.matches(t) && dayOfMonth.matches(t);
}

From source file:cz.muni.fi.pv168.frontend.EventForm.java

private Event getEventFromForm() {

    String eventName = jTextFieldFullname.getText();
    if (eventName == null || eventName.isEmpty()) {
        warningMessageBox(Localization.getRbTexts().getString("name-null"));
        return null;
    }//ww  w  .  j a  v a2  s  .co  m

    DateTime startDate = new DateTime(startDateDtp.getDate());
    DateTime startDateTime = new DateTime(startDateSpinner.getValue());
    LocalDateTime startTime = LocalDateTime.of(startDate.getYear(), startDate.getMonthOfYear(),
            startDate.getDayOfMonth(), startDateTime.getHourOfDay(), startDateTime.getMinuteOfHour(),
            startDateTime.getSecondOfMinute());
    log.debug("SpinnerDateModel: " + startDateTime);

    DateTime endDate = new DateTime(endDateDtp.getDate());
    DateTime endDateTime = new DateTime(endDateSpinner.getValue());
    LocalDateTime endTime = LocalDateTime.of(endDate.getYear(), endDate.getMonthOfYear(),
            endDate.getDayOfMonth(), endDateTime.getHourOfDay(), endDateTime.getMinuteOfHour(),
            endDateTime.getSecondOfMinute());
    log.debug("SpinnerDateModel: " + endDateTime);

    String description = jTextFieldDescription.getText();
    if (description == null) {
        description = "";
    }

    User user = context.getUserTableModel()
            .getUserByEmail((String) jComboBoxUsersInEventForm.getSelectedItem());
    event.setEventName(eventName);
    event.setStartDate(startTime);
    event.setEndDate(endTime);
    event.setDescription(description);
    event.setUserId(user.getId());

    log.debug("Category is" + (Category) jComboBoxCategory.getSelectedItem());
    event.setCategory((Category) jComboBoxCategory.getSelectedItem());

    return event;
}

From source file:de.chaosfisch.google.youtube.upload.Upload.java

License:Open Source License

@SuppressWarnings("MagicNumber")
public void setDateTimeOfRelease(final DateTime dateTimeOfRelease) {
    if (null == dateTimeOfRelease || dateTimeOfRelease.isBeforeNow()) {
        this.dateTimeOfRelease = null;
    } else {//from  w  w  w  .j a  va 2 s  .  co m
        final int mod = dateTimeOfRelease.getMinuteOfHour() % 30;
        this.dateTimeOfRelease = dateTimeOfRelease.plusMinutes(16 > mod ? -mod : 30 - mod).minuteOfHour()
                .roundFloorCopy();
    }
}

From source file:de.dmarcini.submatix.android4.full.comm.BlueThoothComService.java

License:Open Source License

  /**
 * //  w  w  w  . ja  v a2 s. co m
 * schreibe Datum und Zeit in das Gert
 * 
 * Project: SubmatixBTLoggerAndroid Package: de.dmarcini.submatix.android4.comm
 * 
 * 
 * Stand: 27.10.2013
 * 
 * @param cf
 * @param dTime
 * @throws FirmwareNotSupportetException
 * 
 */
public void writeDateTimeToDevice( SPX42Config cf, DateTime dTime ) throws FirmwareNotSupportetException
{
  String kdoString;
  //
  //
  if( !cf.isFirmwareSupported() )
  {
    Log.e( TAG, "firmware not supportet for write settings!" );
    throw new FirmwareNotSupportetException( "write datetime to device" );
  }
  if( cf.canSetDateTime() )
  {
    //
    // Setze das Zeit und Datum als Kommandostring zusammen
    //
    kdoString = String.format( "%s~%x:%02x:%02x:%02x:%02x:%02x%s", ProjectConst.STX, ProjectConst.SPX_DATETIME, dTime.getHourOfDay(), dTime.getMinuteOfHour(),
            dTime.getDayOfMonth(), dTime.getMonthOfYear(), dTime.getYearOfCentury(), ProjectConst.ETX );
    {
      if( ApplicationDEBUG.DEBUG ) Log.d( TAG, "writeDateTimeToDevice()...send <" + kdoString + "> (DATETIME)" );
    }
    this.writeToDevice( kdoString );
  }
  else
  {
    if( ApplicationDEBUG.DEBUG ) Log.d( TAG, "writeDateTimeToDevice()...Firmware not support <set datetime> yet" );
  }
}

From source file:de.dmarcini.submatix.android4.full.gui.SPX42ExportLogFragment.java

License:Open Source License

  /**
 * //from  ww  w.ja va  2 s.  c o  m
 * Exportiere einen Eintrag in eigenem Thread
 * 
 * Project: SubmatixBTLoggerAndroid Package: de.dmarcini.submatix.android4.full.gui
 * 
 * Stand: 09.01.2014
 * 
 * @param rlo
 */
private void exportLogItemsAsThread( final Vector<ReadLogItemObj> lItems, File _tempDir )
{
  final Vector<ReadLogItemObj> rlos = new Vector<ReadLogItemObj>( lItems );
  final File tempDir = _tempDir;
  Thread exportThread = null;
  //
  exportThread = new Thread() {
    @Override
    public void run()
    {
      UDDFFileCreateClass uddfClass = null;
      String uddfFileName = null;
      //
      try
      {
        // erzeuge eine Klasse zum generieren der Exort-UDDF-Files
        uddfClass = new UDDFFileCreateClass();
        //
        // Lass dir einen Namen einfallen
        //
        if( rlos.size() == 0 )
        {
          Log.e( TAG, "exportThread: not selected divelog in parameters found! ABORT EXPORT!" );
          mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
          return;
        }
        if( rlos.size() == 1 )
        {
          if( ApplicationDEBUG.DEBUG ) Log.i( TAG, String.format( "exportThread: export dive %d db-id: %d...", rlos.firstElement().numberOnSPX, rlos.firstElement().dbId ) );
          DateTime st = new DateTime( rlos.firstElement().startTimeMilis );
          uddfFileName = String.format( Locale.ENGLISH, "%s%sdive_%07d_at_%04d%02d%02d%02d%02d%02d.uddf", tempDir.getAbsolutePath(), File.separator,
                  rlos.firstElement().numberOnSPX, st.getYear(), st.getMonthOfYear(), st.getDayOfMonth(), st.getHourOfDay(), st.getMinuteOfHour(), st.getSecondOfMinute() );
        }
        else
        {
          if( ApplicationDEBUG.DEBUG ) Log.i( TAG, String.format( "exportThread: export %d dives ...", rlos.size() ) );
          DateTime st = new DateTime( rlos.firstElement().startTimeMilis );
          uddfFileName = String.format( Locale.ENGLISH, "%s%sdive_%07d_at_%04d%02d%02d%02d%02d%02d-plus-%03d.uddf", tempDir.getAbsolutePath(), File.separator,
                  rlos.firstElement().numberOnSPX, st.getYear(), st.getMonthOfYear(), st.getDayOfMonth(), st.getHourOfDay(), st.getMinuteOfHour(), st.getSecondOfMinute(),
                  rlos.size() );
        }
        //
        // erzeuge die XML...
        //
        if( ApplicationDEBUG.DEBUG ) Log.d( TAG, "create uddf-file: <" + uddfFileName + ">" );
        uddfClass.createXML( new File( uddfFileName ), mHandler, rlos, isFileZipped );
        //
        // melde das Ende an den UI-Thread
        //
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_LOGEXPORTED, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_LOGEXPORTED ) ).sendToTarget();
      }
      catch( ParserConfigurationException ex )
      {
        theToast.showConnectionToastAlert( ex.getLocalizedMessage() );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
      catch( TransformerException ex )
      {
        theToast.showConnectionToastAlert( ex.getLocalizedMessage() );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
      catch( TransformerFactoryConfigurationError ex )
      {
        theToast.showConnectionToastAlert( ex.getLocalizedMessage() );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
      catch( XMLFileCreatorException ex )
      {
        theToast.showConnectionToastAlert( ex.getLocalizedMessage() );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
      catch( DOMException ex )
      {
        theToast.showConnectionToastAlert( runningActivity.getResources().getString( R.string.toast_export_internal_xml_error ) );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
      catch( NoXMLDataFileFoundException ex )
      {
        theToast.showConnectionToastAlert( runningActivity.getResources().getString( R.string.toast_export_cant_find_xmldata ) );
        Log.e( TAG, ex.getLocalizedMessage() );
        mHandler.obtainMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR, new BtServiceMessage( ProjectConst.MESSAGE_LOCAL_EXPORTERR ) ).sendToTarget();
        return;
      }
    }
  };
  exportThread.setName( "log_export_thread" );
  exportThread.start();
}

From source file:de.dmarcini.submatix.android4.full.utils.UDDFFileCreateClass.java

License:Open Source License

  /**
 * //from   w w  w  .  j a v a  2s .c  o  m
 * Tauchgang Teilbaum bauen
 * 
 * Project: SubmatixXMLTest Package: de.dmarcini.bluethooth.submatix.xml
 * 
 * @author Dirk Marciniak (dirk_marciniak@arcor.de)
 * 
 *         Stand: 25.10.2011
 * @param doc
 *          Document Objekt
 * @param diveNumber
 *          Nummer des Tauchganges in der Datenbank
 * @return Teilbaum Tauchgang
 * 
 *         TODO Swasser/Salzwasser Dichte eintragen (Datenbankfeld einrichten)
 * @throws NoXMLDataFileFoundException
 * @throws DOMException
 */
private Node makeDiveNode( Document doc, ReadLogItemObj rlo ) throws DOMException, NoXMLDataFileFoundException
{
  Element diveNode, dateNode, yNode, mNode, dNode;
  Element timeNode, hNode, minNode;
  Element dnNode, atNode, ltNode, gdNode, deNode, noNode, txNode;
  String year, month, day, hour, minute;
  String temperature, lowesttemp;
  String greatestdepth;
  String density;
  //
  DateTime startDateTime = new DateTime( rlo.startTimeMilis );
  day = String.format( Locale.ENGLISH, "%02d", startDateTime.getDayOfMonth() );
  month = String.format( Locale.ENGLISH, "%02d", startDateTime.getMonthOfYear() );
  year = String.format( Locale.ENGLISH, "%04d", startDateTime.getYear() );
  hour = String.format( Locale.ENGLISH, "02d", startDateTime.getHourOfDay() );
  minute = String.format( Locale.ENGLISH, "%02d", startDateTime.getMinuteOfHour() );
  temperature = String.format( Locale.ENGLISH, "%.1f", rlo.firstTemp + ProjectConst.KELVIN );
  lowesttemp = String.format( Locale.ENGLISH, "%.1f", rlo.lowTemp + ProjectConst.KELVIN );
  greatestdepth = String.format( Locale.ENGLISH, "%.1f", rlo.maxDepth / 10.0f );
  density = "1034.0";
  diveNode = doc.createElement( "dive" );
  diveNode.setAttribute( "id", String.format( "%d", rlo.numberOnSPX ) );
  // # date
  dateNode = doc.createElement( "date" );
  // ## date -> year
  yNode = doc.createElement( "year" );
  yNode.appendChild( doc.createTextNode( year ) );
  dateNode.appendChild( yNode );
  // ## date -> month
  mNode = doc.createElement( "month" );
  mNode.appendChild( doc.createTextNode( month ) );
  dateNode.appendChild( mNode );
  // ## date -> day
  dNode = doc.createElement( "day" );
  dNode.appendChild( doc.createTextNode( day ) );
  dateNode.appendChild( dNode );
  diveNode.appendChild( dateNode );
  // # time
  timeNode = doc.createElement( "time" );
  // ## time -> hour
  hNode = doc.createElement( "hour" );
  hNode.appendChild( doc.createTextNode( hour ) );
  timeNode.appendChild( hNode );
  // ## time -> minute
  minNode = doc.createElement( "minute" );
  minNode.appendChild( doc.createTextNode( minute ) );
  timeNode.appendChild( minNode );
  diveNode.appendChild( timeNode );
  // # divenumber
  dnNode = doc.createElement( "divenumber" );
  dnNode.appendChild( doc.createTextNode( String.format( "%d", rlo.numberOnSPX ) ) );
  diveNode.appendChild( dnNode );
  // # airtemp
  atNode = doc.createElement( "airtemperature" );
  atNode.appendChild( doc.createTextNode( temperature ) );
  diveNode.appendChild( atNode );
  // # lowesttemp
  ltNode = doc.createElement( "lowesttemperature" );
  ltNode.appendChild( doc.createTextNode( lowesttemp ) );
  diveNode.appendChild( ltNode );
  // # greatestdepth
  gdNode = doc.createElement( "greatestdepth" );
  gdNode.appendChild( doc.createTextNode( greatestdepth ) );
  diveNode.appendChild( gdNode );
  // # density
  deNode = doc.createElement( "density" );
  deNode.appendChild( doc.createTextNode( density ) );
  diveNode.appendChild( deNode );
  // # notes
  noNode = doc.createElement( "notes" );
  txNode = doc.createElement( "text" );
  txNode.appendChild( doc.createTextNode( rlo.notes ) );
  noNode.appendChild( txNode );
  diveNode.appendChild( noNode );
  // Teilbaum einhngen
  diveNode.appendChild( makeSamplesForDive( doc, rlo ) );
  return( diveNode );
}

From source file:de.dmarcini.submatix.pclogger.comm.BTCommunication.java

License:Open Source License

@Override
public void writeDateTimeToDevice(DateTime dTime) {
    String kdoString;//from   w w  w. ja  va2 s . co m
    //
    if (isConnected) {
        //
        // Setze das Zeit und Datum als Kommandostring zusammen
        //
        kdoString = String.format("%s~%x:%02x:%02x:%02x:%02x:%02x%s", ProjectConst.STX,
                ProjectConst.SPX_DATETIME, dTime.getHourOfDay(), dTime.getMinuteOfHour(), dTime.getDayOfMonth(),
                dTime.getMonthOfYear(), dTime.getYearOfCentury(), ProjectConst.ETX);
        {
            lg.debug("writeDateTimeToDevice()...send <" + kdoString + "> (DATETIME)");
        }
        this.writeToDevice(kdoString);
    }
}