List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:cron.DayOfMonthField.java
License:Open Source License
public boolean matches(DateTime time) { if (unspecified) return true; final int dayOfMonth = time.getDayOfMonth(); if (lastDay) { return dayOfMonth == time.dayOfMonth().withMaximumValue().getDayOfMonth(); } else if (nearestWeekday) { int dayOfWeek = time.getDayOfWeek(); if ((dayOfWeek == DateTimeConstants.MONDAY && contains(time.minusDays(1).getDayOfMonth())) || (dayOfWeek == DateTimeConstants.FRIDAY && contains(time.plusDays(1).getDayOfMonth()))) { return true; }//from w ww . ja v a2s . c o m } return contains(dayOfMonth); }
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 av a2 s. com 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.byteholder.geoclipse.preferences.PrefPageMapProviders.java
License:Open Source License
private void onExportMP() { final FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setText(Messages.Pref_Map_Dialog_Export_Title); dialog.setFilterPath(_prefStore.getString(EXPORT_FILE_PATH)); dialog.setFilterExtensions(new String[] { "*.*", "xml" });//$NON-NLS-1$ //$NON-NLS-2$ dialog.setFilterNames(new String[] { Messages.PrefPageMapProviders_Pref_Map_FileDialog_AllFiles, Messages.PrefPageMapProviders_Pref_Map_FileDialog_XmlFiles }); final DateTime today = new DateTime(); // add leading 0 when necessary final String month = CHARACTER_0 + Integer.toString(today.getMonthOfYear()); final String day = CHARACTER_0 + Integer.toString(today.getDayOfMonth()); final String currentDate = // UI.DASH + Integer.toString(today.getYear()) + UI.DASH + month.substring(month.length() - 2, month.length()) + UI.DASH + day.substring(day.length() - 2, day.length()); dialog.setFileName(_selectedMapProvider.getId() + currentDate + XML_EXTENSION); final String selectedFilePath = dialog.open(); if (selectedFilePath == null) { // dialog is canceled return;/*from ww w . jav a 2s . c o m*/ } final File exportFilePath = new Path(selectedFilePath).toFile(); // keep path _prefStore.setValue(EXPORT_FILE_PATH, exportFilePath.getPath()); if (exportFilePath.exists()) { if (UI.confirmOverwrite(exportFilePath) == false) { // don't overwrite file, nothing more to do return; } } MapProviderManager.getInstance().exportMapProvider(_selectedMapProvider, exportFilePath); _mpViewer.getTable().setFocus(); }
From source file:de.dmarcini.submatix.android4.full.comm.BlueThoothComService.java
License:Open Source License
/** * /*from www . j ava 2 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 w w w .j a va2s. co 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 ww .ja v a2s. 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 .java 2 s.com // 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); } }
From source file:de.speexx.jira.jan.command.transition.IssueTransitionFetcher.java
License:Open Source License
LocalDate createLocalDate(final DateTime dt) { final int year = dt.getYear(); final int month = dt.getMonthOfYear(); final int day = dt.getDayOfMonth(); return LocalDate.of(year, month, day); }
From source file:divconq.lang.BigDateTime.java
License:Open Source License
/** * @param date translates into BigDateTime *//*w ww. j av a2s.co m*/ public BigDateTime(DateTime date) { if (date == null) return; // make sure we are using ISO and UTC date = date.toDateTime(ISOChronology.getInstanceUTC()); //date = date.toDateTime(DateTimeZone.UTC); this.year = 50000000000L + date.getYear(); // ISO says 1 BCE = 0, 2 BCE = -1, etc this.month = date.getMonthOfYear(); this.day = date.getDayOfMonth(); this.hour = date.getHourOfDay(); this.minute = date.getMinuteOfHour(); this.second = date.getSecondOfMinute(); }
From source file:divconq.scheduler.limit.CheckInfo.java
License:Open Source License
public void setWhen(DateTime when) { this.when = when; this.dayOfMonth = when.getDayOfMonth(); this.dayOfWeek = when.getDayOfWeek(); this.monthOfYear = when.getMonthOfYear(); this.monthPlacement = ((this.dayOfMonth - 1) / 7) + 1; this.isLastPlacement = ((when.dayOfMonth().withMaximumValue().getDayOfMonth() - this.dayOfMonth) < 7); this.setLastDay((when.dayOfMonth().withMaximumValue().getDayOfMonth() == this.dayOfMonth)); }