List of usage examples for java.util Date getMinutes
@Deprecated public int getMinutes()
From source file:opensource.zeocompanion.ZeoCompanionApplication.java
private void configAlarmManagerToPrefs() { // setup a daily alarm if auto-emailing is enabled SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean enabledAutoEmail = prefs.getBoolean("email_auto_enable", false); boolean enabledDatabaseReplicate = prefs.getBoolean("database_replicate_zeo", false); long desiredTOD = prefs.getLong("email_auto_send_time", 0); // will default to midnight long configuredTOD = prefs.getLong("email_auto_send_time_configured", 0); // will default to midnight // determine whether there is an active AlarmManager entry that we have established AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent intentCheck = new Intent(this, ZeoCompanionApplication.AlarmReceiver.class); intentCheck.setAction(ZeoCompanionApplication.ACTION_ALARMMGR_WAKEUP_RTC); PendingIntent existingPi = PendingIntent.getBroadcast(this, 0, intentCheck, PendingIntent.FLAG_NO_CREATE); if (enabledAutoEmail || enabledDatabaseReplicate) { // Daily AlarmManager is needed if (existingPi != null && desiredTOD != configuredTOD) { // there is an existing AlarmManager entry, but it has the incorrect starting time-of-day; // so cancel it, and rebuild a new one Intent intent1 = new Intent(this, ZeoCompanionApplication.AlarmReceiver.class); intent1.setAction(ZeoCompanionApplication.ACTION_ALARMMGR_WAKEUP_RTC); PendingIntent pi1 = PendingIntent.getBroadcast(this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi1);//from w w w .j a v a2 s . c om pi1.cancel(); existingPi = null; } if (existingPi == null) { // there is no existing AlarmManager entry, so create it Date dt = new Date(desiredTOD); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, dt.getHours()); calendar.set(Calendar.MINUTE, dt.getMinutes()); calendar.set(Calendar.SECOND, dt.getSeconds()); Intent intent2 = new Intent(this, ZeoCompanionApplication.AlarmReceiver.class); intent2.setAction(ZeoCompanionApplication.ACTION_ALARMMGR_WAKEUP_RTC); PendingIntent pi2 = PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT); am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pi2); SharedPreferences.Editor editor = prefs.edit(); editor.putLong("email_auto_send_time_configured", desiredTOD); editor.commit(); } } else { // Daily AlarmManager is not needed if (existingPi != null) { // there is an AlarmManager entry pending; need to cancel it Intent intent3 = new Intent(this, ZeoCompanionApplication.AlarmReceiver.class); intent3.setAction(ZeoCompanionApplication.ACTION_ALARMMGR_WAKEUP_RTC); PendingIntent pi3 = PendingIntent.getBroadcast(this, 0, intent3, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi3); pi3.cancel(); } } }
From source file:com.openedit.BaseWebPageRequest.java
public String getMinutes(String inDate) { if (inDate == null) { return null; }//from ww w . j av a2s.c om Date date = getLocaleManager().getDateStorageUtil().parseFromStorage(inDate); if (date == null) { return null; } return String.valueOf(date.getMinutes()); }
From source file:org.openmrs.module.dhisconnector.api.impl.DHISConnectorServiceImpl.java
@SuppressWarnings("deprecation") @Override// w w w . j a v a 2 s .c o m public String getLastSyncedAt() { File backup = new File(OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DHIS2BACKUP_FOLDER + File.separator + "api"); if (dhis2BackupExists()) { Date lastModified = new Date(backup.lastModified()); return Context.getDateFormat().format(lastModified) + " " + lastModified.getHours() + ":" + lastModified.getMinutes() + ":" + lastModified.getSeconds(); } else { return ""; } }
From source file:voldemort.store.cachestore.impl.CacheStore.java
public void backup(String path, int threshold) { packLock.lock();/* w w w . j a va 2 s .co m*/ try { checkPath(path); Date date = new Date(); String filename = path + "/" + getNamePrefix() + getCurIndex() + "." + date.getMonth() + "." + date.getDate() + "." + date.getHours() + "." + date.getMinutes(); backupTask = new BackupThread(this, curIndex, filename); backupTask.run(); //new BackupThread(this, curIndex, filename).start(threshold); } finally { packLock.unlock(); } }
From source file:com.hhunj.hhudata.ForegroundService.java
boolean IsDuringWorkHours(Date dt) { /*/* w w w.j a v a2 s. c o m*/ // UTC Calendar calendar = Calendar.getInstance(); int offset = calendar.get(Calendar.ZONE_OFFSET); int dst = calendar.get(Calendar.DST_OFFSET); calendar.setTimeInMillis(dt.getTime()); calendar.add(Calendar.MILLISECOND, (offset + dst)); Date resultDate = calendar.getTime(); // int offset=dt.getTimezoneOffset(); */ int hour = dt.getHours(); int minute = dt.getMinutes(); int ftime = hour * 100 + minute; int fstart = m_workStartTime.getHours() * 100 + m_workStartTime.getMinutes(); int fend = m_workEndTime.getHours() * 100 + m_workEndTime.getMinutes(); return (ftime >= fstart && ftime < fend); }
From source file:TimeFormatter.java
/** * Format the given date as a string, according to the given * format string.// w w w .j a va 2s. c om * The format string is of the form used by the strftime(3) UNIX * call. * @param date The date to format * @param format The formatting string * @return the String with the formatted date. */ public static String format(Date date, String format) { StringBuffer buf = new StringBuffer(50); char ch; for (int i = 0; i < format.length(); i++) { ch = format.charAt(i); if (ch == '%') { ++i; if (i == format.length()) break; ch = format.charAt(i); if (ch == 'E') { // Alternate Era ++i; } else if (ch == 'Q') { // Alternate numeric symbols ++i; } if (i == format.length()) break; ch = format.charAt(i); switch (ch) { case 'A': buf.append(fullWeekDays[date.getDay()]); break; case 'a': buf.append(abrWeekDays[date.getDay()]); break; case 'B': buf.append(fullMonths[date.getMonth()]); break; case 'b': case 'h': buf.append(abrMonths[date.getMonth()]); break; case 'C': appendPadded(buf, (date.getYear() + 1900) / 100, 2); break; case 'c': buf.append(date.toLocaleString()); break; case 'D': buf.append(TimeFormatter.format(date, "%m/%d/%y")); break; case 'd': appendPadded(buf, date.getDate(), 2); break; case 'e': appendPadded(buf, date.getMonth() + 1, 2, ' '); break; case 'H': appendPadded(buf, date.getHours(), 2); break; case 'I': case 'l': int a = date.getHours() % 12; if (a == 0) a = 12; appendPadded(buf, a, 2, ch == 'I' ? '0' : ' '); break; case 'j': buf.append("[?]"); // No simple way to get this as of now break; case 'k': appendPadded(buf, date.getHours(), 2, ' '); break; case 'M': appendPadded(buf, date.getMinutes(), 2); break; case 'm': appendPadded(buf, date.getMonth() + 1, 2); break; case 'n': buf.append('\n'); break; case 'p': buf.append(date.getHours() < 12 ? "am" : "pm"); break; case 'R': buf.append(TimeFormatter.format(date, "%H:%M")); break; case 'r': buf.append(TimeFormatter.format(date, "%l:%M%p")); break; case 'S': appendPadded(buf, date.getSeconds(), 2); break; case 'T': buf.append(TimeFormatter.format(date, "%H:%M:%S")); break; case 't': buf.append('\t'); break; case 'U': case 'u': case 'V': case 'W': buf.append("[?]"); // Weekdays are a pain, especially // without day of year (0-365) ; break; case 'w': buf.append(date.getDay()); break; case 'X': buf.append(TimeFormatter.format(date, "%H:%M:%S")); break; case 'x': buf.append(TimeFormatter.format(date, "%B %e, %Y")); break; case 'y': appendPadded(buf, (date.getYear() + 1900) % 100, 2); break; case 'Y': appendPadded(buf, (date.getYear() + 1900), 4); break; case 'Z': String strdate = date.toString(); buf.append(strdate.substring(20, 23)); // (!) // There should be a better way // to do this... break; case '%': buf.append('%'); break; } } else { buf.append(ch); } } return buf.toString(); }
From source file:com.krawler.spring.crm.common.crmManagerDAOImpl.java
/** * To convert a date and time selected separately by user into corresponding combined datetime * from users selected timezone to systems timezone * * The first step is to keep track of the time difference in order to change the date if required. * Two time only objects dtold and dtcmp are created for this purpose. * * The date passed and the time passed that are in system timezone are formatted without * timezone and then parsed into the required timezone and then the time values are set * back to the date value sent./*from ww w. j a v a 2 s . c om*/ * **/ public Date converttz(String timeZoneDiff, Date dt, String time) { Calendar cal = Calendar.getInstance(); try { if (timeZoneDiff == null || timeZoneDiff.isEmpty()) { timeZoneDiff = "-7:00"; } String val; SimpleDateFormat sdf = new SimpleDateFormat("HHmm 'Hrs'"); Date dtold = sdf.parse("0000 Hrs"); if (!time.endsWith("Hrs")) { sdf = new SimpleDateFormat("hh:mm a"); dtold = sdf.parse("00:00 AM"); } SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); sdf2.setTimeZone(TimeZone.getTimeZone("GMT" + timeZoneDiff)); // Setting the timezone passed Date dt1 = sdf.parse(time); // Setting the passed time to the date object in system timezone sdf.setTimeZone(TimeZone.getTimeZone("GMT" + timeZoneDiff)); // Setting the timezone passed Date dtcmp = sdf.parse(time); // Parsing the time to timezone using passed values dt1.setMonth(dt.getMonth()); // Setting the date values sent to the system time only value dt1.setDate(dt.getDate()); dt1.setYear(dt.getYear()); dt1 = sdf2.parse(sdf1.format(dt1)); // Parsing datetime into required timezone dt.setHours(dt1.getHours()); // Setting the time values into the sent date dt.setMinutes(dt1.getMinutes()); dt.setSeconds(0); cal.setTime(dt); if (dtcmp.compareTo(dtold) < 0) { // Comparing for time value change cal.add(Calendar.DATE, -1); // in order to change the date accordingly } dtold.setDate(2); if (dtcmp.compareTo(dtold) > 0 || dtcmp.compareTo(dtold) == 0) { cal.add(Calendar.DATE, 1); } } catch (ParseException ex) { System.out.println(ex); } finally { return cal.getTime(); } }
From source file:com.cssweb.android.view.TrendView.java
private void repairData() throws JSONException { close = quoteData.getDouble("close"); high = quoteData.getDouble("high"); low = quoteData.getDouble("low"); jrkp = quoteData.getDouble("jrkp"); Date dt = new Date(); int year = dt.getYear(); int month = dt.getMonth(); int day = dt.getDate(); int hour = dt.getHours(); int minute = dt.getMinutes(); JSONArray list = quoteData.getJSONArray("data"); if (quoteData.getString("quotetime") != null && !quoteData.getString("quotetime").equals("")) { year = Integer.parseInt(quoteData.getString("quotetime").substring(0, 4)); month = Integer.parseInt(quoteData.getString("quotetime").substring(5, 7)) - 1; day = Integer.parseInt(quoteData.getString("quotetime").substring(8, 10)); hour = Integer.parseInt(quoteData.getString("quotetime").substring(11, 13)); minute = Integer.parseInt(quoteData.getString("quotetime").substring(14, 16)); dt = new Date(year, month, day, hour, minute); }//from w w w. j ava 2 s . c o m JSONArray jsonArray = new JSONArray(); if ("hk".equals(exchange)) { this.MINUTES = 300; Date dt1 = new Date(year, month, day, 9, 30); Date dt2 = new Date(year, month, day, 12, 0); Date dt3 = new Date(year, month, day, 13, 31); Date dt4 = new Date(year, month, day, 16, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 151; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 151 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 301; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null" || quoteData.getString("quotetime").equals("")) { hopelen = 1; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 151) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 151 && i <= 301) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 151))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("close")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else if ("cf".equals(exchange)) { this.MINUTES = 270; Date dt1 = new Date(year, month, day, 9, 15); Date dt2 = new Date(year, month, day, 11, 30); Date dt3 = new Date(year, month, day, 13, 1); Date dt4 = new Date(year, month, day, 15, 15); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 136; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 136 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 271; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 136) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 136 && i <= 271) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 136))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("jrkp")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else if ("dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) { this.MINUTES = 225; Date dt1 = new Date(year, month, day, 9, 0); Date dt2 = new Date(year, month, day, 10, 15); Date dt3 = new Date(year, month, day, 10, 31); Date dt4 = new Date(year, month, day, 11, 30); Date dt5 = new Date(year, month, day, 13, 31); Date dt6 = new Date(year, month, day, 15, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 76; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 76 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime() && dt.getTime() < dt5.getTime()) { hopelen = 136; } if (dt.getTime() >= dt5.getTime() && dt.getTime() < dt6.getTime()) { hopelen = 136 + (dt.getTime() - dt5.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt6.getTime()) { hopelen = 226; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 76) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 76 && i < 136) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 76))); } if (i >= 136 && i <= 226) { time = Utils.format(new Date(dt5.getTime() + 1000 * 60 * (i - 136))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("jrkp")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } else { Date dt1 = new Date(year, month, day, 9, 30); Date dt2 = new Date(year, month, day, 11, 30); Date dt3 = new Date(year, month, day, 13, 1); Date dt4 = new Date(year, month, day, 15, 0); long hopelen = 0; if (dt.getTime() < dt1.getTime()) { // 0 ? hopelen = 0; } if (dt.getTime() >= dt1.getTime() && dt.getTime() < dt2.getTime()) { hopelen = (dt.getTime() - dt1.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt2.getTime() && dt.getTime() < dt3.getTime()) { hopelen = 121; } if (dt.getTime() >= dt3.getTime() && dt.getTime() < dt4.getTime()) { hopelen = 121 + (dt.getTime() - dt3.getTime()) / 1000 / 60 + 1; } if (dt.getTime() >= dt4.getTime()) { hopelen = 241; } //?9.15 9.25 if (quoteData.getString("quotetime") == "null") { hopelen = 0; } String time = ""; for (int i = 0; i < hopelen; i++) { if (i < 121) { time = Utils.format(new Date(dt1.getTime() + 1000 * 60 * i)); } if (i >= 121 && i <= 241) { time = Utils.format(new Date(dt3.getTime() + 1000 * 60 * (i - 121))); } Boolean flag = false; JSONArray json = new JSONArray(); for (int j = 0; j < list.length(); j++) { if (list.getJSONArray(j).getString(3).equals(time)) { json.put(0, list.getJSONArray(j).getDouble(0)); json.put(1, list.getJSONArray(j).getDouble(1)); json.put(2, list.getJSONArray(j).getDouble(2)); json.put(3, list.getJSONArray(j).getString(3)); json.put(4, 1);//?? if (i == 0) { json.put(5, list.getJSONArray(j).getDouble(1));//?? json.put(6, list.getJSONArray(j).getDouble(2));//?? } else { if (jsonArray.getJSONArray(i - 1).getInt(4) == 1) { json.put(5, list.getJSONArray(j).getDouble(1) - jsonArray.getJSONArray(i - 1).getInt(1)); json.put(6, list.getJSONArray(j).getDouble(2) - jsonArray.getJSONArray(i - 1).getInt(2)); } else { json.put(5, 0); json.put(6, 0); } } //json.put(7, (list.getJSONArray(j).getDouble(2)/list.getJSONArray(j).getDouble(1))/100);//? flag = true; break; } } //? if (!flag) { if (i == 0) { json.put(1, 0); json.put(2, 0); json.put(3, time); json.put(0, quoteData.getDouble("close")); } else { json.put(1, jsonArray.getJSONArray(i - 1).getDouble(1)); json.put(2, jsonArray.getJSONArray(i - 1).getDouble(2)); json.put(3, time); json.put(0, ((JSONArray) jsonArray.get(i - 1)).getDouble(0)); } json.put(4, 0); json.put(5, 0); json.put(6, 0); json.put(7, 0); } jsonArray.put(json); } } //Log.i("#########getSecurityType##########", NameRule.getSecurityType(exchange, stockcode)+">>>>>>>>>>>>>>"); // if(NameRule.getSecurityType(exchange, stockcode)==15 // || NameRule.getSecurityType(exchange, stockcode)==5 // || NameRule.getSecurityType(exchange, stockcode)==35){ // quoteArray = null; // return; // }else{ // quoteArray = jsonArray; // } quoteArray = jsonArray; actualDataLen = quoteArray.length(); if (!isTrackStatus) isTrackNumber = actualDataLen - 1;//?? highvolume = TickUtil.gethighVolume(quoteArray); highamount = TickUtil.gethighAmount(quoteArray); high = Math.max(TickUtil.gethighPrice(quoteArray, quoteArray.length()), close); low = Math.min(TickUtil.getlowPrice(quoteArray, quoteArray.length()), close); if ("sz399001".equals(exchange + stockcode) || "sh000001".equals(exchange + stockcode)) { //?????? int len = quoteData.getJSONArray("data2").length() - 1; high = Math.max(high, TickUtil.gethighPrice(quoteData.getJSONArray("data2"), len)); low = Math.min(low, TickUtil.getlowPrice(quoteData.getJSONArray("data2"), len)); } }
From source file:net.cit.tetrad.resource.SubResource.java
private void setSliderBarDateBytimeUnit(CommonDto dto) throws ParseException { String timeUnit = dto.getGraph_period(); int totalRange = DHTML_TOTAL_RANGE_1MIN; int searchRange = DHTML_SEARCH_RANGE_1MIN; if (timeUnit != null) { if (timeUnit.equals("5")) { totalRange = DHTML_TOTAL_RANGE_5MIN; searchRange = DHTML_SEARCH_RANGE_5MIN; } else if (timeUnit.equals("30")) { totalRange = DHTML_TOTAL_RANGE_30MIN; searchRange = DHTML_SEARCH_RANGE_30MIN; } else if (timeUnit.equals("60")) { totalRange = DHTML_TOTAL_RANGE_60MIN; searchRange = DHTML_SEARCH_RANGE_60MIN; }// www. j a va 2s . c o m } int halfMin = searchRange / 2; String inputDate = dto.getSelectDate(); Date nowDate = new Date(); Date standardDateObj = DateUtil.plusMinute(nowDate, -(halfMin)); // (?? ) Date searchSdateObj = DateUtil.plusMinute(nowDate, -searchRange); Date searchEdateObj = nowDate; Date totalMinObj = DateUtil.plusHour(nowDate, -totalRange); Date totalMaxObj = nowDate; // ? ? if ((dto.getMemo() == null || dto.getMemo().isEmpty()) && (inputDate != null && !inputDate.isEmpty())) { String fullDate = inputDate + " " + dto.getSelectHour() + ":" + dto.getSelectMin(); standardDateObj = DateUtil.dateformat(fullDate, "yyyy-MM-dd HH:mm"); searchSdateObj = DateUtil.plusMinute(standardDateObj, -halfMin); searchEdateObj = DateUtil.plusMinute(standardDateObj, halfMin); totalMinObj = DateUtil.plusHour(searchEdateObj, -totalRange); totalMaxObj = searchEdateObj; } dto.setSelectDate(DateUtil.getCurrentDate(standardDateObj, "yyyy-MM-dd")); dto.setSelectHour(standardDateObj.getHours()); dto.setSelectMin(standardDateObj.getMinutes()); dto.setSliderMin(DateUtil.getCurrentDate(totalMinObj, "yyyy-MM-dd HH:mm")); dto.setSliderMax(DateUtil.getCurrentDate(totalMaxObj, "yyyy-MM-dd HH:mm")); dto.setSdate(DateUtil.getCurrentDate(searchSdateObj, "yyyy-MM-dd HH:mm")); dto.setEdate(DateUtil.getCurrentDate(searchEdateObj, "yyyy-MM-dd HH:mm")); }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testRemoveTimeFromDate() { final Date date = Const.removeTimeFromDate(new Date()); assertEquals(0, date.getHours());//from w w w.ja v a 2s . c o m assertEquals(0, date.getMinutes()); assertEquals(0, date.getSeconds()); }