List of usage examples for org.joda.time DateTime monthOfYear
public Property monthOfYear()
From source file:org.trakhound.www.trakhound.device_details.DeviceStatus.java
License:Open Source License
public static DeviceStatus get(UserConfiguration userConfig, String uniqueId) { if (userConfig != null) { DateTime now = DateTime.now(); DateTime from = new DateTime(now.year().get(), now.monthOfYear().get(), now.dayOfMonth().get(), 0, 0, 0);/*from w ww . j a v a 2 s . c o m*/ DateTime to = from.plusDays(1); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String fromStr = fmt.print(from); String toStr = fmt.print(to); String urlSuffix = "data/get/?" + "token=" + userConfig.sessionToken + "&sender_id=" + UserManagement.getSenderId() + "&devices=[{\"unique_id\":\"" + uniqueId + "\"}]" + "&from=" + fromStr + "&to=" + toStr + "&command=" + "01111"; // Get Status, Controller, Oee, and Timers tables String url = Uri.withAppendedPath(ApiConfiguration.apiHost, urlSuffix).toString(); String response = Requests.get(url); if (response != null && response.length() > 0) { try { JSONArray a = new JSONArray(response); if (a.length() > 0) { JSONObject obj = a.getJSONObject(0); DeviceStatus deviceStatus = new DeviceStatus(); deviceStatus.uniqueId = obj.getString("unique_id"); deviceStatus.statusInfo = StatusInfo.parse(obj.getJSONObject("status")); deviceStatus.controllerInfo = ControllerInfo.parse(obj.getJSONObject("controller")); deviceStatus.oeeInfo = OeeInfo.parse(obj.getJSONObject("oee")); deviceStatus.timersInfo = TimersInfo.parse(obj.getJSONObject("timers")); return deviceStatus; } } catch (JSONException ex) { Log.d("Exception", ex.getMessage()); } } } return null; }
From source file:org.trakhound.www.trakhound.device_list.DeviceStatus.java
License:Open Source License
public static DeviceStatus[] get(UserConfiguration userConfig) { if (userConfig != null) { try {//from w ww .jav a 2 s. c o m DateTime now = DateTime.now(); DateTime from = new DateTime(now.year().get(), now.monthOfYear().get(), now.dayOfMonth().get(), 0, 0, 0); DateTime to = from.plusDays(1); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String fromStr = fmt.print(from); String toStr = fmt.print(to); String urlSuffix = "data/get/?" + "token=" + URLEncoder.encode(userConfig.sessionToken, "UTF-8") + "&sender_id=" + URLEncoder.encode(UserManagement.getSenderId(), "UTF-8") + "&from=" + fromStr + "&to=" + toStr + "&command=0101"; // Get Status and Oee tables String url = Uri.withAppendedPath(ApiConfiguration.apiHost, urlSuffix).toString(); String response = Requests.get(url); if (response != null && response.length() > 0) { ArrayList<DeviceStatus> devicesStatuses = new ArrayList<>(); try { JSONArray a = new JSONArray(response); for (int i = 0; i < a.length(); i++) { JSONObject obj = a.getJSONObject(i); DeviceStatus deviceStatus = new DeviceStatus(); deviceStatus.uniqueId = obj.getString("unique_id"); deviceStatus.statusInfo = StatusInfo.parse(obj.getJSONObject("status")); deviceStatus.oeeInfo = OeeInfo.parse(obj.getJSONObject("oee")); devicesStatuses.add(deviceStatus); } } catch (JSONException ex) { Log.d("Exception", ex.getMessage()); } DeviceStatus[] deviceStatusArray = new DeviceStatus[devicesStatuses.size()]; return devicesStatuses.toArray(deviceStatusArray); } } catch (UnsupportedEncodingException ex) { Log.d("Exception", ex.getMessage()); } } return null; }
From source file:test.sql.CustomerDataManager.java
License:Apache License
public String makeSubject() { // String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8); DateTime now = new DateTime(); int year, month, day, hour, minute, second; year = now.year().get();/* w ww.j a v a2 s .c o m*/ month = now.monthOfYear().get(); day = now.dayOfMonth().get(); hour = now.getHourOfDay(); minute = now.getMinuteOfHour(); second = now.getSecondOfMinute(); StringBuilder sb = new StringBuilder(); sb.append(LINKAGE_SUBJECT_PREFIX); sb.append(StressTester.randomString(8)); sb.append("_"); sb.append(Integer.toString(year)); if (month < 10) sb.append("0"); sb.append(Integer.toString(month)); if (day < 10) sb.append("0"); sb.append(Integer.toString(day)); sb.append("_"); if (hour < 10) sb.append("0"); sb.append(Integer.toString(hour)); if (minute < 10) sb.append("0"); sb.append(Integer.toString(minute)); if (second < 10) sb.append("0"); sb.append(Integer.toString(second)); return sb.toString(); }
From source file:test.sql.TrackingDataManager.java
License:Apache License
public String makeSubject() { String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8); DateTime now = new DateTime(); int year, month, day, hour, minute, second; year = now.year().get();/*from www . ja v a 2 s . co m*/ month = now.monthOfYear().get(); day = now.dayOfMonth().get(); hour = now.getHourOfDay(); minute = now.getMinuteOfHour(); second = now.getSecondOfMinute(); StringBuilder sb = new StringBuilder(); sb.append(LINKAGE_SUBJECT_PREFIX); sb.append(StressTester.randomString(8)); sb.append("_"); sb.append(Integer.toString(year)); if (month < 10) sb.append("0"); sb.append(Integer.toString(month)); if (day < 10) sb.append("0"); sb.append(Integer.toString(day)); sb.append("_"); if (hour < 10) sb.append("0"); sb.append(Integer.toString(hour)); if (minute < 10) sb.append("0"); sb.append(Integer.toString(minute)); if (second < 10) sb.append("0"); sb.append(Integer.toString(second)); return sb.toString(); }
From source file:test.utilities.SemStoreLeakConverter.java
License:Apache License
void processLine(String line, PrintStream ps) throws Exception { if (line == null) return;// w ww . j a va 2s . co m StringTokenizer tokens = new StringTokenizer(line); if (tokens.countTokens() == 0) return; String dstr = tokens.nextToken(); String tstr = tokens.nextToken(); String datestr = dstr + "T" + tstr; DateTime dtime = new DateTime(datestr); // peel off Info: String info = tokens.nextToken(); // peel off [Event String event = tokens.nextToken(); // grab hold of operation with trailing ] String operation = tokens.nextToken(); int bracket = operation.indexOf(']'); if (bracket > 0) operation = operation.substring(0, bracket); // type of TripleStore in hand String storeType = tokens.nextToken(); // the operation again String op = tokens.nextToken(); // the address String addrStr = tokens.nextToken(); int eq = addrStr.indexOf('='); if (eq > 0) addrStr = addrStr.substring(eq + 1); String memsize = null; // if it's a created line, we might have a trailing , and a mem size out there if (op.equals("created:")) { int comma = addrStr.indexOf(','); if (comma > 0) addrStr = addrStr.substring(0, comma); try { memsize = tokens.nextToken(); if (memsize != null) { eq = memsize.indexOf('='); if (eq > 0) memsize = memsize.substring(eq + 1); } } catch (ArrayIndexOutOfBoundsException e) { } } int month = dtime.monthOfYear().get(); int day = dtime.monthOfYear().get(); int hour = dtime.hourOfDay().get(); int minute = dtime.minuteOfHour().get(); int seconds = dtime.secondOfMinute().get(); int millis = dtime.millisOfSecond().get(); // construct a key String subject = "tstore:" + dtime.year().getAsText() + (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day) + (hour < 10 ? "0" + hour : hour) + (minute < 10 ? "0" + minute : minute) + (seconds < 10 ? "0" + seconds : seconds) + "." + (millis < 100 ? "0" : "") + (millis < 10 ? "0" + millis : millis) + "_" + operation; ps.println(subject + "\t" + "tstore:timestamp" + "\t\"" + dtime.toLocalDateTime() + "\"^^xsd:dateTime ."); ps.println(subject + "\t" + "tstore:type" + "\t\"" + operation + "\" ."); ps.println(subject + "\t" + "tstore:address" + "\t\"" + addrStr + "\" ."); if (memsize != null) ps.println(subject + "\t" + "tstore:memsize" + "\t\"" + memsize + "\"^^xsd:integer ."); ps.println(""); }
From source file:TVShowTimelineMaker.timeConstraints.dayAcceptors.SameTimeAsDayAcceptor.java
public boolean accept2(DateTime inDateTime) { boolean rValue = true; for (DayEvent<?, ?> curEvent : this.Events) { boolean foundMatch = false; if (curEvent instanceof OnceDayEvent) { NavigableSet<DateTime> curPossibleDays = ((OnceDayEvent) curEvent).getPossibleDays(); for (DateTime curDateTime : curPossibleDays) { if ((inDateTime.monthOfYear().get() == curDateTime.monthOfYear().get()) && (inDateTime.dayOfMonth().get() == curDateTime.dayOfMonth().get())) { foundMatch = true;//from w w w . j a v a 2 s. c o m break; } } } else if (curEvent instanceof YearlyDayEvent) { NavigableSet<DayOfYear> curPossibleDays = ((YearlyDayEvent) curEvent).getPossibleDays(); for (DayOfYear curDateTime : curPossibleDays) { if ((inDateTime.monthOfYear().get() == curDateTime.getMonth()) && (inDateTime.dayOfMonth().get() == curDateTime.getDay())) { foundMatch = true; break; } } } if (!foundMatch) { rValue = false; break; } } return rValue; }
From source file:TVShowTimelineMaker.timeConstraints.dayAcceptors.SameTimeAsDayAcceptor.java
public boolean accept2(DayOfYear inDateTime) { boolean rValue = true; for (DayEvent<?, ?> curEvent : this.Events) { boolean foundMatch = false; if (curEvent instanceof OnceDayEvent) { NavigableSet<DateTime> curPossibleDays = ((OnceDayEvent) curEvent).getPossibleDays(); for (DateTime curDateTime : curPossibleDays) { if ((inDateTime.getMonth() == curDateTime.monthOfYear().get()) && (inDateTime.getDay() == curDateTime.dayOfMonth().get())) { foundMatch = true;/*from w ww . jav a 2 s .c om*/ break; } } } else if (curEvent instanceof YearlyDayEvent) { NavigableSet<DayOfYear> curPossibleDays = ((YearlyDayEvent) curEvent).getPossibleDays(); for (DayOfYear curDateTime : curPossibleDays) { if ((inDateTime.getMonth() == curDateTime.getMonth()) && (inDateTime.getDay() == curDateTime.getDay())) { foundMatch = true; break; } } } if (!foundMatch) { rValue = false; break; } } return rValue; }