Project

General

Profile

« Previous | Next » 

Revision f1a25720

Added by Katja Luther over 6 years ago

  • ID f1a25720755daa96e8838a617a660dfced7b9f31
  • Parent 23e50194

first implementation for change from joda time to java8 time

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/in/SDDImport.java
14 14
import java.net.MalformedURLException;
15 15
import java.net.URI;
16 16
import java.net.URL;
17
import java.text.SimpleDateFormat;
17
import java.time.LocalDateTime;
18
import java.time.ZoneId;
19
import java.time.ZonedDateTime;
20
import java.time.format.DateTimeFormatter;
18 21
import java.util.ArrayList;
19
import java.util.Date;
20 22
import java.util.HashMap;
21 23
import java.util.HashSet;
22 24
import java.util.List;
......
28 30
import org.apache.log4j.Logger;
29 31
import org.jdom.Element;
30 32
import org.jdom.Namespace;
31
import org.joda.time.DateTime;
32 33
import org.springframework.stereotype.Component;
33 34
import org.springframework.transaction.TransactionStatus;
34 35

  
......
550 551
				int hourOfDay = Integer.parseInt(nameCreated.substring(11,13));
551 552
				int minuteOfHour = Integer.parseInt(nameCreated.substring(14,16));
552 553
				int secondOfMinute = Integer.parseInt(nameCreated.substring(17,19));
553
				DateTime created = new DateTime(year,monthOfYear,dayOfMonth,hourOfDay,minuteOfHour,secondOfMinute,0);
554
				ZonedDateTime created = ZonedDateTime.of(year,monthOfYear,dayOfMonth,hourOfDay,minuteOfHour,secondOfMinute,0, ZoneId.systemDefault());
554 555
				sourceReference.setCreated(created);
555 556
				sec.setCreated(created);
556 557
			}
......
833 834
			String stringDateModified = (String)ImportHelper.getXmlInputValue(elRevisionData, "DateModified",sddNamespace);
834 835

  
835 836
			if (stringDateModified != null) {
836
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
837
				Date d = null;
837

  
838
				LocalDateTime ldt = null;
839

  
838 840
				try {
839
					d = sdf.parse(stringDateModified);
841
				    ldt = LocalDateTime.parse(stringDateModified, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'hh:mm:ss"));
840 842
				} catch(Exception e) {
841 843
					System.err.println("Exception :");
842 844
					e.printStackTrace();
843 845
				}
844 846

  
845
				DateTime updated = null;
846
				if (d != null) {
847
					updated = new DateTime(d);
847
				ZonedDateTime updated = null;
848
				if (ldt != null) {
849
					updated = ZonedDateTime.of(null, null, null);
848 850
					sourceReference.setUpdated(updated);
849 851
					sec.setUpdated(updated);
850 852
				}

Also available in: Unified diff