I have started constructing an argument in Java which is the 'DD-MM-yyyy HH: mm: ss' format And display performance output as follows:
If the date is today / tomorrow, it should be: Today / tomorrow HH: mm am / pm - If it is less than 7 days ago: x days ago < Br> If it is more than 7 days ago: last week
similar
two weeks ago
three weeks ago
A month ago (iefour week ago)
2 months ago
.. 11 months First
a year ago
and X-years ago.
I just calculate the exact days from today's date. I came in add-time to make my work easier, but I have not been able to find that there is some underlying stuff in it that will give me the desired output.
int days = Days.daysBetween (new local date), new localet ()). Dots ();
I have written this code for today but I do not know how to add about the rest of the time. Please guide me
I made my argument. Thanks anyway! `String ConvertDetects-Word (String Datestress) throws java.text.ParseException {/ p>
// Here is the format from datestr mysql database:" 2015-03-03 09: 14: 04.0 " ; SimpleDateFormat formatter = New Simple Format ("yyyy-MM-dd HH: mm: ss"); Java.util.Date bDate = formatter.parse (datestr); Calendar Today = Calendar.Justation (); Calendar date = calendar.jistence (); Date.setTime (bDate); String str = ""; String ampm = New Simple Format ("hh: mm a") Format (BDT); IT = IT today. Gate (Calendar: IEER); Int toYear = date.get (Calendar .YEAR); Month from INT = today. Gate (calendar. MONTH) +1; Int toMonth = date.get (Calendar. MONTH) +1; Date.set (calendar.IEER, today.gate (calendar.IEER)); Int today = today.get (Calendar. DAY_OF_YEAR); Int toDay = date.get (Calendar: DAY_OF_YEAR); If (by the year! = ToYear) {str = (from year) + "year (before)"; } And if (silence! = ToMonth) {str = (from month-tomont) + "months ago"; } And {int diff = fromDay- toDay; If (diff == 0) {str = "today" "+ AMM;} if (diff == 1) {str =" tomorrow "" + AMM; } If (diff> = 2 & amp; amp; amp;; diff & lt; 7) {str = "" + diff + "Day before"; Str = getDay (date.get (calendar.DAY_OF_WEEK)) + "|" + AMM; } If (def> = 7 & amp; amp; & amp; & amp; & amp;;; & lt; 14) {str = "last week"; } If (difference) = 14 & amp; Amp; And diff & lt; 21) {str = "2 weeks ago"; } If (diff> = 21 & amp; amp; amp; diff & lt; 28) {str = "3 weeks ago"; } If (diff> = 28) {str = "4 weeks ago"; }} Return string; }
No comments:
Post a Comment