List of usage examples for org.joda.time DateTime toGregorianCalendar
public GregorianCalendar toGregorianCalendar()
java.util.GregorianCalendar
, assigning exactly the same millisecond instant. From source file:io.konig.runtime.io.BaseJsonReader.java
License:Apache License
protected GregorianCalendar dateTime(JsonParser parser) throws IOException { DateTimeFormatter fmt = ISODateTimeFormat.dateOptionalTimeParser(); String text = parser.getValueAsString(); DateTime joda = fmt.parseDateTime(text); return joda.toGregorianCalendar(); }
From source file:name.gano.astro.time.Time.java
License:Open Source License
/** Constructor from Joda DateTime **/ public Time(DateTime time) { time.withZone(DateTimeZone.forTimeZone(tz)); currentTime = time.toGregorianCalendar(); updateTimeMeasures();// w w w.ja v a 2 s .co m }
From source file:nz.co.jsrsolutions.ds3.provider.CMEEodDataProviderCsvParser.java
License:Open Source License
public void parse(InputStream inputStream) throws EodDataProviderException { String line;/*w ww .j a v a2 s. com*/ BufferedReader br; @SuppressWarnings("unused") int lineNumber = 1; // skip the header try { br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); line = br.readLine(); // skip the first line (header) while ((line = br.readLine()) != null) { ++lineNumber; // use comma as separator String[] columns = line.split(","); SYMBOL symbol = new SYMBOL(); symbol.setCode(columns[4]); // CONTRACT symbol.setName(columns[4]); // CONTRACT symbol.setLongName(columns[5]); // PRODUCT DESCRIPTION _symbols.add(symbol); // if there is no settlement for this contract // then ignore this quote if (columns[13].isEmpty()) { continue; } QUOTE quote = new QUOTE(); quote.setSymbol(columns[4]); // CONTRACT quote.setName(columns[4]); // CONTRACT quote.setDescription(columns[5]); // PRODUCT DESCRIPTION if (columns[6].isEmpty()) { quote.setOpen(Double.parseDouble(columns[13])); // SETTLE(?) } else { quote.setOpen(Double.parseDouble(columns[6])); // OPEN } if (columns[11].isEmpty()) { quote.setClose(Double.parseDouble(columns[13])); // SETTLE(?) } else { quote.setClose(Double.parseDouble(columns[11])); // CLOSE } String high = columns[7]; String low = columns[9]; if (!high.isEmpty()) { quote.setHigh(Double.parseDouble(high)); } if (!low.isEmpty()) { quote.setLow(Double.parseDouble(low)); } quote.setVolume(Long.parseLong(columns[15])); if (columns[14].equals("UNCH")) { quote.setChange(0.0); } else { quote.setChange(Double.parseDouble(columns[14])); } quote.setOpenInterest(Long.parseLong(columns[15])); DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd/yyyy"); DateTime dt = formatter.parseDateTime(columns[19]); quote.setDateTime(dt.toGregorianCalendar()); _quotes.add(quote); } } catch (UnsupportedEncodingException e) { throw new EodDataProviderException(e); } catch (IOException e) { throw new EodDataProviderException(e); } }
From source file:org.apache.isis.schema.utils.jaxbadapters.XmlCalendarFactory.java
License:Apache License
public static XMLGregorianCalendar create(DateTime dateTime) { return dateTime != null ? withTypeFactoryDo(dtf -> dtf.newXMLGregorianCalendar(dateTime.toGregorianCalendar())) : null;//from w w w .ja v a 2s.com }
From source file:org.apache.marmotta.commons.sesame.model.LiteralCommons.java
License:Apache License
/** * Create a cache key for the date literal with the given date. Converts the date * to a XMLGregorianCalendar with UTC timezone and then calls the method above. * * @param date date object of the date literal * @param type datatype URI of the literal * @return a 64bit hash key for the literal *//*www . j a va2 s. c o m*/ public static String createCacheKey(DateTime date, String type) { GregorianCalendar cal = date.toGregorianCalendar(); XMLGregorianCalendar xml_cal = dtf.newXMLGregorianCalendar(cal); return createCacheKey(xml_cal.toXMLFormat(), (String) null, type); }
From source file:org.apache.marmotta.commons.util.DateUtils.java
License:Apache License
/** * Transform a Java date into a XML calendar. Useful for working with date literals. * @param date/*from w w w .ja va2s. c o m*/ * @return */ public static XMLGregorianCalendar getXMLCalendar(DateTime date) { GregorianCalendar c = date.toGregorianCalendar(); try { return getDatatypeFactory().newXMLGregorianCalendar(c); } catch (DatatypeConfigurationException e) { return null; } }
From source file:org.archfirst.common.datetime.DateTimeAdapter.java
License:Apache License
public XMLGregorianCalendar marshal(DateTime val) throws Exception { try {/* w w w.j a v a 2s . co m*/ GregorianCalendar calendar = val.toGregorianCalendar(); return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); } catch (DatatypeConfigurationException e) { throw new IllegalArgumentException(); } }
From source file:org.dataconservancy.cos.osf.client.support.DateTimeTransform.java
License:Apache License
@Override public Calendar apply(final DateTime dateTime) { return dateTime.toGregorianCalendar(); }
From source file:org.jasig.portlet.jaxb.util.JodaTypeConverter.java
License:Apache License
public static String printTime(LocalTime localTime) { final DateTime dateTime = localTime.toDateTimeToday(DateTimeZone.UTC); final GregorianCalendar cal = dateTime.toGregorianCalendar(); return DatatypeConverter.printTime(cal); }
From source file:org.jevis.commons.driver.DataSourceHelper.java
License:Open Source License
public static List<String> getFTPMatchedFileNames(FTPClient fc, DateTime lastReadout, String filePath) { filePath = filePath.replace("\\", "/"); String[] pathStream = getPathTokens(filePath); String startPath = ""; if (filePath.startsWith("/")) { startPath = "/"; }// ww w . j a v a 2 s . co m List<String> folderPathes = getMatchingPathes(startPath, pathStream, new ArrayList<String>(), fc, lastReadout, new DateTimeFormatterBuilder()); // System.out.println("foldersize,"+folderPathes.size()); List<String> fileNames = new ArrayList<String>(); if (folderPathes.isEmpty()) { org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, "Cant find suitable folder on the device"); return fileNames; } // String fileName = null; String fileNameScheme = pathStream[pathStream.length - 1]; String currentfolder = null; try { for (String folder : folderPathes) { // fc.changeWorkingDirectory(folder); // System.out.println("currentFolder,"+folder); currentfolder = folder; // for (FTPFile file : fc.listFiles(folder)) { // System.out.println(file.getName()); // } fc.changeWorkingDirectory(folder); for (FTPFile file : fc.listFiles()) { // org.apache.log4j.Logger.getLogger(Launcher.class.getName()).log(org.apache.log4j.Level.ALL, "CurrentFileName: " + fileName); // fileName = removeFoler(fileName, folder); if (file.getTimestamp().compareTo(lastReadout.toGregorianCalendar()) < 0) { continue; } boolean match = false; System.out.println(file.getName()); if (DataSourceHelper.containsTokens(fileNameScheme)) { boolean matchDate = matchDateString(file.getName(), fileNameScheme); DateTime folderTime = getFileTime(folder + file.getName(), pathStream); boolean isLater = folderTime.isAfter(lastReadout); if (matchDate && isLater) { match = true; } } else { Pattern p = Pattern.compile(fileNameScheme); Matcher m = p.matcher(file.getName()); match = m.matches(); } if (match) { fileNames.add(folder + file.getName()); } } } } catch (IOException ex) { org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, ex.getMessage()); } catch (Exception ex) { org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, "Error while searching a matching file"); org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, "Folder: " + currentfolder); org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, "FileName: " + fileNameScheme); org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, ex.getMessage()); } if (folderPathes.isEmpty()) { org.apache.log4j.Logger.getLogger(DataSourceHelper.class).log(org.apache.log4j.Level.ERROR, "Cant find suitable files on the device"); } // System.out.println("filenamesize"+fileNames.size()); return fileNames; }