Java Year Month toYearMonth(String dateString)

Here you can find the source of toYearMonth(String dateString)

Description

to Year Month

License

Apache License

Declaration

public static Date toYearMonth(String dateString) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.google.common.base.Strings;

public class Main {
    private static final SimpleDateFormat YEAR_MONTH_FORMAT = new SimpleDateFormat("yyyy-MM");

    public static Date toYearMonth(String dateString) {
        if (Strings.isNullOrEmpty(dateString)) {
            return null;
        }/*from ww w  . jav  a  2s .  com*/
        try {
            return YEAR_MONTH_FORMAT.parse(dateString);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. parseMonthAndYearStringOrNull(String dateString)
  2. sameYearAndMonth(Date d1, Date d2)
  3. toDateProgression(int year, int month, int day, String seed, int pedometer)
  4. toDateProgression(int year, int month, int day, String seed, int pedometer)
  5. todaySubtract(String years, String months)