Here you can find the source of parseYearFromDate(String longDate)
Parameter | Description |
---|---|
longDate | The formatted long date |
public static String parseYearFromDate(String longDate)
//package com.java2s; /**//from w w w . ja va 2 s .c o m * DateTimeUtils.java * * A utility class for converting dates to common formats * * @author Robin Andersson, Johan Brook * @copyright (c) 2012 Robin Andersson, Johan Brook, Mattias Henriksson, Lisa Stenberg * @license MIT */ public class Main { /** * Return the release year from a date on the format "YYYY-MM-DD". * * @param longDate * The formatted long date * @return The year as a string on the format "YYYY". If the parameter is * not well formated ("YYYY-MM-DD") the parameter is returned * untouched. */ public static String parseYearFromDate(String longDate) { if (longDate == null) return null; int index = longDate.indexOf("-"); return (index != -1) ? longDate.substring(0, index) : longDate; } }