Here you can find the source of getQuarterLastMonth(String quarter)
Parameter | Description |
---|---|
quarter | quarter number |
public static String getQuarterLastMonth(String quarter)
//package com.java2s; public class Main { /**/*from ww w . j ava 2s. c o m*/ * Determine the last month of each quarter based on quarter. * * <pre> * examples: * DateUtils.getLastMonth("201201") = "201203" * DateUtils.getLastMonth("201202") = "201206" * DateUtils.getLastMonth("201203") = "201209" * DateUtils.getLastMonth("201204") = "201212" * other conditions will return null. * </pre> * * @param quarter quarter number * @return String, the return value will be: yyyy03, yyyy06, yyyy09, yyyy12. */ public static String getQuarterLastMonth(String quarter) { if (null == quarter) { return null; } String year = quarter.substring(0, 4); String quart = quarter.substring(4, 6); String month = ""; if (quart.equals("01")) { month = "03"; } else if (quart.equals("02")) { month = "06"; } else if (quart.equals("03")) { month = "09"; } else if (quart.equals("04")) { month = "12"; } else { return null; } return year + month; } }