List of usage examples for java.util Date getDate
@Deprecated public int getDate()
From source file:com.krawler.esp.servlets.importProjectPlanCSV.java
public String getActualDuration(Date stdate, Date enddate, int[] NonWorkDays, String[] holidays) { int noofdays = 0; java.text.SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("yyyy-MM-dd"); try {/*from w ww . ja v a 2 s .c om*/ Calendar c1 = Calendar.getInstance(); while (stdate.compareTo(enddate) < 0) { if (Arrays.binarySearch(NonWorkDays, stdate.getDay()) < 0 && Arrays.binarySearch(holidays, sdf1.format(stdate)) < 0) { noofdays++; } c1.set(stdate.getYear() + 1900, stdate.getMonth(), stdate.getDate()); c1.add(Calendar.DATE, 1); stdate = sdf1.parse(sdf1.format(c1.getTime())); } if (stdate.compareTo(enddate) == 0) { if (Arrays.binarySearch(NonWorkDays, stdate.getDay()) < 0 && Arrays.binarySearch(holidays, sdf1.format(stdate)) < 0) { noofdays++; } } } catch (ParseException ex) { Logger.getLogger(importProjectPlanCSV.class.getName()).log(Level.SEVERE, null, ex); } return noofdays + "d"; }
From source file:com.ridgelineapps.wallpaper.photosite.FlickrUtils.java
String formatDate(Date date) { date = new Date(date.getTime() - (1000 * 60 * 60 * 24)); String year = "" + (date.getYear() + 1900); String month = "" + (date.getMonth() + 1); String day = "" + (date.getDate()); if (month.length() < 2) { month = "0" + month; }/* w ww . j av a2 s . c o m*/ if (day.length() < 2) { day = "0" + day; } return year + "-" + month + "-" + day; }
From source file:com.homeworkreminder.Main.java
@SuppressWarnings("deprecation") private static boolean initInfoListForDate(Date date) { // TODO Auto-generated method stub // find the corresponding list<Task> in the hashmap // give this list to the listview Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, date.getYear() + 1900); c.set(Calendar.MONTH, date.getMonth()); c.set(Calendar.DAY_OF_MONTH, date.getDate()); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0);//w w w . j a va2 s . co m c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); List<Task> l = TaskMap.get(c); if (l == null) { tv_calendar_notaskfordate.setVisibility(View.VISIBLE); List<Task> i = new ArrayList<Task>(); info_adapter = new InfoListAdapter(context, R.layout.calendar_info_single_row, i); info_list.setAdapter(info_adapter); info_list.setVisibility(View.GONE); return false; } else { if (!l.isEmpty()) { info_list.setVisibility(View.VISIBLE); tv_calendar_notaskfordate.setVisibility(View.GONE); info_adapter = new InfoListAdapter(context, R.layout.calendar_info_single_row, l); info_list.setAdapter(info_adapter); info_list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub Intent intent = new Intent(context, EditTask.class); Bundle b = new Bundle(); b.putInt("id", info_adapter.getId(position)); intent.putExtra("info", b); context.startActivity(intent); } }); return true; } else { info_list.setVisibility(View.GONE); tv_calendar_notaskfordate.setVisibility(View.VISIBLE); return false; } } }
From source file:org.pentaho.di.repository.RepositoryTestBase.java
@SuppressWarnings("deprecation") private int getDate(Date date) { return date.getDate(); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorTest.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); ModelInfo info = createModel();/*from ww w .j a v a 2s.co m*/ CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] == null); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals(null, cells[4]); // IfNull value does not seem to work assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorIT.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL = System.getProperty("KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL", "N"); ModelInfo info = createModel();//from www . ja v a 2s .co m CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertTrue("".equals(cells[4])); } else { assertTrue(cells[4] == null); } assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertEquals("", cells[4]); assertEquals(cells[4], ""); } else { assertEquals(null, cells[4]); // IfNull value does not seem to work } assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
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 a va 2 s . co 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:forseti.JUtil.java
@SuppressWarnings("deprecation") public static synchronized int obtDia(Date fech) { return fech.getDate(); }
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 w w w.jav a2 s .c o m*/ * **/ 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.android.mms.ui.MessageUtils.java
public static String getTimeDividerString(Context context, long when) { Time then = new Time(); then.set(when);/*from w w w . j ava 2s . c om*/ Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int formatFlags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { formatFlags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. formatFlags |= DateUtils.FORMAT_SHOW_DATE; Date curDate = new Date(); Date cur = new Date(curDate.getYear(), curDate.getMonth(), curDate.getDate(), 0, 0, 0); long oneDay = 24 * 60 * 60 * 1000; long elapsedTime = cur.getTime() - when; if (elapsedTime < oneDay && elapsedTime > 0) { return context.getResources().getString(R.string.str_ipmsg_yesterday); } } else { return context.getString(R.string.str_ipmsg_today); } return DateUtils.formatDateTime(context, when, formatFlags); }