The SOLR time format is 2015-07-06t00:00:00.0z, so the following is the conversion of the current time
SimpleDateFormat format =NewSimpleDateFormat ("Yyyy-mm-dd ' T ' HH:mm:ssZ"); //Date d = format.parse (Str.replace ("Z", "UTC"));//Note is the space +UTC//System.out.println (d);Date date=NewDate (); Calendar Calendar=calendar.getinstance (); Calendar.set (Calendar.hour_of_day, Calendar.get (calendar.hour_of_day)-1); SYSTEM.OUT.PRINTLN (date); String Temp=Format.format (date); String hours=Format.format (Calendar.gettime ()); SYSTEM.OUT.PRINTLN (temp); System.out.println (":::"+hours); intEnd=temp.indexof ("+"); String Re=temp.substring (0,end) + "Z"; intEnd2=hours.indexof ("+"); String Re2=hours.substring (0,end2) + "Z"; System.out.println ("Current Time" +re); System.out.println ("One hour before" +Re2); Try{System.out.println (Format.parse (Re.replace ("Z", "UTC"))); } Catch(ParseException E1) {//TODO auto-generated Catch blockE1.printstacktrace (); }
Java Query SOLR time format