Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Joda DateTime library and update to java.time package #575

Merged
merged 12 commits into from
Oct 29, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -28,7 +29,6 @@

import org.apache.commons.io.FileUtils;
import org.eclipse.core.runtime.Platform;
import org.joda.time.DateTime;

import org.locationtech.udig.omsbox.OmsBoxPlugin;
import org.locationtech.udig.omsbox.utils.OmsBoxConstants;
Expand Down Expand Up @@ -180,7 +180,7 @@ public Process exec( String script, final PrintStream internalStream, final Prin
// environment.put("CLASSPATH", classPath);

final Process process = processBuilder.start();
internalStream.println("Process started: " + new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
internalStream.println("Process started: " + LocalDateTime.now().format(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
internalStream.println("");

// command launched
Expand Down Expand Up @@ -247,7 +247,7 @@ public void run() {
internalStream.println("");
internalStream.println("");
internalStream.println("Process finished: "
+ new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
+ LocalDateTime.now().format(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
};
}.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
*/
package org.locationtech.udig.omsbox.utils;

import java.time.format.DateTimeFormatter;
import java.util.HashMap;

import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class OmsBoxConstants {
public static final String CATEGORY_OTHERS = "Others";
Expand All @@ -38,8 +37,8 @@ public class OmsBoxConstants {
public static final String STATISTICS = "Statistics";

public static String dateTimeFormatterYYYYMMDDHHMMSS_string = "yyyy-MM-dd HH:mm:ss";
public static DateTimeFormatter dateTimeFormatterYYYYMMDDHHMMSS = DateTimeFormat
.forPattern(dateTimeFormatterYYYYMMDDHHMMSS_string);
public static DateTimeFormatter dateTimeFormatterYYYYMMDDHHMMSS = DateTimeFormatter
.ofPattern(dateTimeFormatterYYYYMMDDHHMMSS_string);

public static String LOGLEVEL_GUI_ON = "ON";
public static String LOGLEVEL_GUI_OFF = "OFF";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import i18n.omsbox.Messages;

import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -47,7 +48,6 @@
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.part.ViewPart;
import org.joda.time.DateTime;

import org.locationtech.udig.omsbox.OmsBoxPlugin;
import org.locationtech.udig.omsbox.core.ModuleDescription;
Expand Down Expand Up @@ -397,9 +397,9 @@ public void runSelectedModule() throws Exception {
if (script == null) {
return;
}

String scriptID = currentSelectedModuleGui.getModuleDescription().getName() + " "
+ new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
+ LocalDateTime.now().format(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
handler.runModule(scriptID, script);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.time.LocalDateTime;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
Expand All @@ -23,8 +24,6 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.joda.time.DateTime;

import org.locationtech.udig.omsbox.OmsBoxPlugin;
import org.locationtech.udig.omsbox.core.IProcessListener;
import org.locationtech.udig.omsbox.core.JConsoleOutputConsole;
Expand Down Expand Up @@ -83,7 +82,7 @@ private void execute( String path ) {
Process process = executor.exec(path, internalStream, errorStream, loggerLevelGui, ramLevel);

File scriptFile = new File(path);
scriptID = scriptFile.getName() + " " + new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
scriptID = scriptFile.getName() + " " + LocalDateTime.now().format(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
OmsBoxPlugin.getDefault().addProcess(process, scriptID);

// cleanup when leaving uDig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@
package org.locationtech.udig.omsbox.view.actions;

import java.io.File;

import org.locationtech.udig.ui.ExceptionDetailsDialog;
import java.time.LocalDateTime;

import org.apache.commons.io.FileUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.joda.time.DateTime;

import org.locationtech.udig.omsbox.OmsBoxPlugin;
import org.locationtech.udig.omsbox.utils.OmsBoxConstants;
import org.locationtech.udig.omsbox.view.OmsBoxView;
import org.locationtech.udig.ui.ExceptionDetailsDialog;
fgdrf marked this conversation as resolved.
Show resolved Hide resolved

/**
* @author Andrea Antonello (www.hydrologis.com)
Expand All @@ -53,7 +50,7 @@ public void run( IAction action ) {
File tempFile = File.createTempFile("omsbox_", ".oms");
if (tempFile == null || !tempFile.exists() || tempFile.getAbsolutePath() == null) {
// try with user's home folder
String ts = new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
String ts = LocalDateTime.now().format(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS);
String userHomePath = System.getProperty("user.home"); //$NON-NLS-1$

File userHomeFile = new File(userHomePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import org.locationtech.udig.catalog.IGeoResource;
import org.locationtech.udig.ui.ExceptionDetailsDialog;
import org.locationtech.udig.ui.PlatformGIS;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;
Expand All @@ -25,13 +21,13 @@
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.geotools.data.simple.SimpleFeatureSource;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import org.locationtech.udig.catalog.IGeoResource;
import org.locationtech.udig.catalog.kml.core.KmlToolPlugin;
import org.locationtech.udig.catalog.kml.core.KmlUtils;
import org.locationtech.udig.catalog.kml.internal.Messages;
import org.locationtech.udig.catalog.kml.internal.ui.ImageConstants;
import org.locationtech.udig.ui.ExceptionDetailsDialog;
import org.locationtech.udig.ui.PlatformGIS;

/**
* @author Andrea Antonello (www.hydrologis.com)
Expand All @@ -41,7 +37,6 @@ public class KmlExportWizard extends Wizard implements IExportWizard {

public static boolean canFinish = false;
private KmlExportWizardPage mainPage;
public static DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyyMMddHHmm"); //$NON-NLS-1$

public KmlExportWizard() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.SortedSet;

import org.locationtech.udig.project.IMap;
import org.locationtech.udig.project.internal.Map;
import org.locationtech.udig.project.internal.render.RenderManager;
import org.locationtech.udig.project.internal.render.ViewportModel;
import org.locationtech.udig.project.render.IViewportModelListener;
import org.locationtech.udig.project.render.displayAdapter.MapDisplayEvent;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
Expand All @@ -28,11 +22,15 @@
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.joda.time.DateTime;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.udig.project.IMap;
import org.locationtech.udig.project.internal.Map;
import org.locationtech.udig.project.internal.render.RenderManager;
import org.locationtech.udig.project.internal.render.ViewportModel;
import org.locationtech.udig.project.render.IViewportModelListener;
import org.locationtech.udig.project.render.displayAdapter.MapDisplayEvent;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

public class TestViewportModel implements ViewportModel {

Expand Down Expand Up @@ -336,17 +334,17 @@ public void setIsBoundsChanging(boolean changing) {
}

@Override
public List<DateTime> getAvailableTimesteps() {
public List<LocalDateTime> getAvailableTimesteps() {
return null;
}

@Override
public DateTime getCurrentTimestep() {
public LocalDateTime getCurrentTimestep() {
return null;
}

@Override
public void setCurrentTimestep(DateTime value) {
public void setCurrentTimestep(LocalDateTime value) {

}

Expand Down
1 change: 0 additions & 1 deletion plugins/org.locationtech.udig.libs/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
<classpathentry exported="true" kind="lib" path="lib/javax.mail-1.5.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jdom2-2.0.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jgridshift-core-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/joda-time-1.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/json-simple-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jsqlparser-0.3.14.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jt-affine-1.1.12.jar"/>
Expand Down
10 changes: 1 addition & 9 deletions plugins/org.locationtech.udig.libs/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ Bundle-ClassPath: .,
lib/javax.mail-1.5.0.jar,
lib/jdom2-2.0.6.jar,
lib/jgridshift-core-1.2.jar,
lib/joda-time-1.6.jar,
lib/json-simple-1.1.jar,
lib/json-simple-1.1.jar,
lib/jsqlparser-0.3.14.jar,
lib/jt-affine-1.1.12.jar,
lib/jt-algebra-1.1.12.jar,
Expand Down Expand Up @@ -1145,13 +1144,6 @@ Export-Package: .,
org.jdom2.xpath;version="2.0.6",
org.jdom2.xpath.jaxen;version="2.0.6",
org.jdom2.xpath.util;version="2.0.6",
org.joda.time;version="1.6.0",
org.joda.time.base;version="1.6.0",
org.joda.time.chrono;version="1.6.0",
org.joda.time.convert;version="1.6.0",
org.joda.time.field;version="1.6.0",
org.joda.time.format;version="1.6.0",
org.joda.time.tz;version="1.6.0",
org.json.simple;version="1.1.0",
org.json.simple.parser;version="1.1.0",
org.locationtech.jts;version="1.16.1",
Expand Down
1 change: 0 additions & 1 deletion plugins/org.locationtech.udig.libs/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ bin.includes = .,\
lib/javax.mail-1.5.0.jar,\
lib/jdom2-2.0.6.jar,\
lib/jgridshift-core-1.2.jar,\
lib/joda-time-1.6.jar,\
lib/json-simple-1.1.jar,\
lib/jsqlparser-0.3.14.jar,\
lib/jt-affine-1.1.12.jar,\
Expand Down
6 changes: 0 additions & 6 deletions plugins/org.locationtech.udig.libs/pom-libs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,6 @@
<artifactId>gt-gtopo30</artifactId>
<version>${geotools.version}</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>it.geosolutions.imageio-ext</groupId>
<artifactId>imageio-ext-streams</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.time.LocalDateTime;
import java.util.List;
import java.util.SortedSet;

Expand All @@ -21,7 +22,6 @@
import org.eclipse.emf.ecore.EObject;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.crs.DefaultEngineeringCRS;
import org.joda.time.DateTime;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.locationtech.jts.geom.Coordinate;
Expand Down Expand Up @@ -455,14 +455,14 @@ public void setBounds(double minx, double maxx, double miny, double maxy)
*
* @model
*/
public List<DateTime> getAvailableTimesteps();
public List<LocalDateTime> getAvailableTimesteps();

/**
* Returns the current timestep or null if no time has been defined.
*
* @model
*/
public DateTime getCurrentTimestep();
public LocalDateTime getCurrentTimestep();

/**
* Sets the value of the '{@link org.locationtech.udig.project.internal.render.ViewportModel#getCurrentTimestep <em>Current Timestep</em>}' attribute.
Expand All @@ -472,7 +472,7 @@ public void setBounds(double minx, double maxx, double miny, double maxy)
* @see #getCurrentTimestep()
* @generated
*/
void setCurrentTimestep(DateTime value);
void setCurrentTimestep(LocalDateTime value);

/**
* Returns the available list of elevations or null if no elevation has been defined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -43,7 +44,6 @@
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.geotools.data.Query;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.joda.time.DateTime;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.osgi.framework.Bundle;

Expand Down Expand Up @@ -625,8 +625,8 @@ public String convertReferencedEnvelopeToString(EDataType eDataType, Object inst
* <!-- end-user-doc -->
* @generated
*/
public DateTime createDateTimeFromString(EDataType eDataType, String initialValue) {
return (DateTime) super.createFromString(eDataType, initialValue);
public LocalDateTime createDateTimeFromString(EDataType eDataType, String initialValue) {
return (LocalDateTime) super.createFromString(eDataType, initialValue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.time.LocalDateTime;
import java.util.List;

import java.util.SortedSet;
Expand Down Expand Up @@ -45,7 +46,6 @@
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.geotools.data.Query;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.joda.time.DateTime;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.locationtech.jts.geom.Coordinate;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ public void initializePackageContents() {
!IS_GENERATED_INSTANCE_CLASS);
initEDataType(referencedEnvelopeEDataType, ReferencedEnvelope.class, "ReferencedEnvelope", //$NON-NLS-1$
IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
initEDataType(dateTimeEDataType, DateTime.class, "DateTime", IS_SERIALIZABLE, //$NON-NLS-1$
initEDataType(dateTimeEDataType, LocalDateTime.class, "DateTime", IS_SERIALIZABLE, //$NON-NLS-1$
!IS_GENERATED_INSTANCE_CLASS);
initEDataType(illegalArgumentExceptionEDataType, IllegalArgumentException.class,
"IllegalArgumentException", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
Expand Down
Loading