List of usage examples for org.joda.time DateTime getYear
public int getYear()
From source file:controllers.ReporteFechaController.java
public String construirStringFechaYHora(DateTime fechaYHora) { String fechaString = fechaYHora.getDayOfMonth() + "/" + fechaYHora.getMonthOfYear() + "/" + fechaYHora.getYear(); return fechaString; }
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; }//from ww w . j a va 2s . c o 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.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;// w ww. j ava 2 s .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.gui.SPX42ExportLogFragment.java
License:Open Source License
/** * /* w ww. jav a2 s .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
/** * // w w w.ja va2 s . c om * 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.fatalix.book.importer.BookMigrator.java
License:Open Source License
private static BookEntry parseOPF(File pathToOPF, BookEntry bmd) throws IOException { List<String> lines = Files.readAllLines(pathToOPF.toPath(), Charset.forName("UTF-8")); boolean multiLineDescription = false; String description = ""; for (String line : lines) { if (multiLineDescription) { multiLineDescription = false; if (line.split("<").length == 1) { multiLineDescription = true; description = description + line; } else { description = description + line.split("<")[0]; description = StringEscapeUtils.unescapeXml(description); bmd.setDescription(description); }// w ww . j a va 2s .c om } else if (line.contains("dc:title")) { String title = line.split(">")[1].split("<")[0]; bmd.setTitle(title); } else if (line.contains("dc:creator")) { String creator = line.split(">")[1].split("<")[0]; bmd.setAuthor(creator); } else if (line.contains("dc:description")) { String value = line.split(">")[1]; if (value.split("<").length == 1) { multiLineDescription = true; description = value; } else { value = value.split("<")[0]; value = StringEscapeUtils.unescapeXml(value); bmd.setDescription(value); } } else if (line.contains("dc:publisher")) { String value = line.split(">")[1].split("<")[0]; bmd.setPublisher(value); } else if (line.contains("dc:date")) { String value = line.split(">")[1].split("<")[0]; DateTime dtReleaseDate = new DateTime(value, DateTimeZone.UTC); if (dtReleaseDate.getYear() != 101) { bmd.setReleaseDate(dtReleaseDate.toDate()); } } else if (line.contains("dc:language")) { String value = line.split(">")[1].split("<")[0]; bmd.setLanguage(value); } else if (line.contains("opf:scheme=\"ISBN\"")) { String value = line.split(">")[1].split("<")[0]; bmd.setIsbn(value); } } return bmd; }
From source file:de.fatalix.book.importer.CalibriImporter.java
private static BookEntry parseOPF(Path pathToOPF, BookEntry bmd) throws IOException { List<String> lines = Files.readAllLines(pathToOPF, Charset.forName("UTF-8")); boolean multiLineDescription = false; String description = ""; for (String line : lines) { if (multiLineDescription) { multiLineDescription = false; if (line.split("<").length == 1) { multiLineDescription = true; description = description + line; } else { description = description + line.split("<")[0]; description = StringEscapeUtils.unescapeXml(description); bmd.setDescription(description); }/*from w w w. j av a 2s . co m*/ } else { if (line.contains("dc:title")) { String title = line.split(">")[1].split("<")[0]; bmd.setTitle(title); } else if (line.contains("dc:creator")) { String creator = line.split(">")[1].split("<")[0]; bmd.setAuthor(creator); } else if (line.contains("dc:description")) { String value = line.split(">")[1]; if (value.split("<").length == 1) { multiLineDescription = true; description = value; } else { value = value.split("<")[0]; value = StringEscapeUtils.unescapeXml(value); bmd.setDescription(value); } } else if (line.contains("dc:publisher")) { String value = line.split(">")[1].split("<")[0]; bmd.setPublisher(value); } else if (line.contains("dc:date")) { String value = line.split(">")[1].split("<")[0]; DateTime dtReleaseDate = new DateTime(value); if (dtReleaseDate.getYear() != 101) { bmd.setReleaseDate(dtReleaseDate.toDate()); } } else if (line.contains("dc:language")) { String value = line.split(">")[1].split("<")[0]; bmd.setLanguage(value); } else if (line.contains("opf:scheme=\"ISBN\"")) { String value = line.split(">")[1].split("<")[0]; bmd.setIsbn(value); } } } return bmd; }
From source file:de.hackerspacebremen.format.SpeakingDateFormat.java
License:Open Source License
private static boolean isThisYear(final DateTime dateTime) { final DateTime now = new DateTime(ZONE); return now.getYear() == dateTime.getYear(); }
From source file:de.hackerspacebremen.transformer.SpeakingDateTransformer.java
License:Open Source License
private boolean isThisYear(final DateTime dateTime) { final DateTime now = new DateTime(ZONE); return now.getYear() == dateTime.getYear(); }