Back to project page Joetz-Android-V2.
The source code is released under:
GNU General Public License
If you think the Android project Joetz-Android-V2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.jens.myapplication.util; import com.example.jens.myapplication.sam.JoetzApplication; /*from w w w.j a v a 2 s .c o m*/ import org.joda.time.DateTime; /** * Created by Sam on 5/11/2014. */ public class DateTimeStringConverter { /** * Creates a simple date string from a DateTime object * @param date The date you want the string for * @return String in the format of "dd mon 'yy" (eg. "12 nov '13") */ public static String getSimpleDate(DateTime date){ String monthShort = JoetzApplication.getContext().getString( MyMonths.getMonthShortResId(date.getMonthOfYear())); return date.getDayOfMonth() + " " + monthShort + " '" + date.getYearOfCentury(); } /** * Simple string showing the range of two dates with a dash as separator * @param startDate * @param endDate * @return 2 date strings separated by a dash symbol */ public static String getSimpleDateRange(DateTime startDate, DateTime endDate){ return getSimpleDateRange(startDate, endDate, "-"); } /** * Simple string showing the range of two dates with the set separator * @param startDate * @param endDate * @param separator Separator to separate the two dates * @return 2 date strings separated by the set separator symbol */ public static String getSimpleDateRange(DateTime startDate, DateTime endDate, String separator){ return getSimpleDate(startDate) + " " + separator + " " + getSimpleDate(endDate); } /** * Get the short 3 letter name for a month * @param date the date to get the month from * @return the 3 letter month string for this date */ public static String getMonthShort(DateTime date){ String monthShort = JoetzApplication.getContext().getString( MyMonths.getMonthShortResId(date.getMonthOfYear())); return monthShort; } }