// Path: common/src/main/java/com/marcohc/architecture/common/util/helper/StringUtils.java
// public final class StringUtils {
// 
//     private static final String EMAIL_PATTERN = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$";
//     private static Pattern pattern;
// 
//     private StringUtils() {
//     }
// 
//     /**
//      * Validate hex with regular expression
//      *
//      * @param email hex for validation
//      * @return true valid hex, false invalid hex
//      */
//     public static boolean isEmailValid(@NonNull final String email) {
//         Preconditions.checkNotNull(email, "email");
//         boolean isValid = false;
//         if (pattern == null) {
//             pattern = Pattern.compile(EMAIL_PATTERN);
//         }
//         isValid = pattern.matcher(email).matches();
//         return isValid;
//     }
// 
//     /**
//      * Check if the parameters is blank.
//      *
//      * @param text the text to check
//      * @return true if is blank, false otherwise
//      */
//     public static boolean isBlank(@Nullable final CharSequence text) {
//         return text == null || text.toString().trim().isEmpty();
//     }
// 
//     /**
//      * Check if the parameters is blank.
//      *
//      * @param text the text to check
//      * @return true if is blank, false otherwise
//      */
//     public static boolean isBlank(@Nullable final String text) {
//         return text == null || text.trim().isEmpty();
//     }
// 
//     @NonNull
//     public static String getFirstCapitalize(@NonNull String text) {
//         Preconditions.checkNotNull(text, "text");
//         StringBuilder textCapitalize = new StringBuilder();
//         if (!text.isEmpty()) {
//             textCapitalize.append(text.substring(0, 1).toUpperCase()).append(text.substring(1, text.length()));
//         }
//         return textCapitalize.toString();
//     }
// 
//     @NonNull
//     public static String getAllCapitalize(@NonNull String text) {
//         Preconditions.checkNotNull(text, "text");
//         StringBuilder textCapitalize = new StringBuilder();
//         if (!text.isEmpty()) {
//             for (int i = 0; i < text.length(); i++) {
//                 textCapitalize.append(String.valueOf(text.charAt(i)).toUpperCase());
//             }
//         }
//         return textCapitalize.toString();
//     }
// 
// }


import com.marcohc.architecture.common.util.helper.StringUtils;
import java.util.Calendar;
import java.util.Locale;
/*
 * Copyright (C) 2015 Marco Hernaiz Cao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.marcohc.architecture.common.util;



/**
 * Calendar and date useful methods
 */
public class DateUtils {

    // ************************************************************************************************************************************************************************
    // * Calendar methods
    // ************************************************************************************************************************************************************************

    public static String formatCurrentMonth(Calendar calendar) {
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarCurrentMonthString() {
        Calendar calendar = Calendar.getInstance();
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarLastMonthString() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarLastThreeMonthsString() {
        String text = "";
        Calendar initCalendar = Calendar.getInstance();
        Calendar endCalendar = getCalendarThreeMonthsAgo();
        endCalendar.add(Calendar.MONTH, 1);
        text = StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", endCalendar).substring(0, 3));
        text += " - " + StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", initCalendar).substring(0, 3));
        return text;
    }

    public static String getCalendarLastSixMonthsString() {
        String text = "";
        Calendar initCalendar = Calendar.getInstance();
        Calendar endCalendar = getCalendarSixMonthsAgo();
        endCalendar.add(Calendar.MONTH, 1);
// Path: common/src/main/java/com/marcohc/architecture/common/util/helper/StringUtils.java
// public final class StringUtils {
// 
//     private static final String EMAIL_PATTERN = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$";
//     private static Pattern pattern;
// 
//     private StringUtils() {
//     }
// 
//     /**
//      * Validate hex with regular expression
//      *
//      * @param email hex for validation
//      * @return true valid hex, false invalid hex
//      */
//     public static boolean isEmailValid(@NonNull final String email) {
//         Preconditions.checkNotNull(email, "email");
//         boolean isValid = false;
//         if (pattern == null) {
//             pattern = Pattern.compile(EMAIL_PATTERN);
//         }
//         isValid = pattern.matcher(email).matches();
//         return isValid;
//     }
// 
//     /**
//      * Check if the parameters is blank.
//      *
//      * @param text the text to check
//      * @return true if is blank, false otherwise
//      */
//     public static boolean isBlank(@Nullable final CharSequence text) {
//         return text == null || text.toString().trim().isEmpty();
//     }
// 
//     /**
//      * Check if the parameters is blank.
//      *
//      * @param text the text to check
//      * @return true if is blank, false otherwise
//      */
//     public static boolean isBlank(@Nullable final String text) {
//         return text == null || text.trim().isEmpty();
//     }
// 
//     @NonNull
//     public static String getFirstCapitalize(@NonNull String text) {
//         Preconditions.checkNotNull(text, "text");
//         StringBuilder textCapitalize = new StringBuilder();
//         if (!text.isEmpty()) {
//             textCapitalize.append(text.substring(0, 1).toUpperCase()).append(text.substring(1, text.length()));
//         }
//         return textCapitalize.toString();
//     }
// 
//     @NonNull
//     public static String getAllCapitalize(@NonNull String text) {
//         Preconditions.checkNotNull(text, "text");
//         StringBuilder textCapitalize = new StringBuilder();
//         if (!text.isEmpty()) {
//             for (int i = 0; i < text.length(); i++) {
//                 textCapitalize.append(String.valueOf(text.charAt(i)).toUpperCase());
//             }
//         }
//         return textCapitalize.toString();
//     }
// 
// }


// Path: util/src/main/java/com/marcohc/architecture/common/util/DateUtils.java
import com.marcohc.architecture.common.util.helper.StringUtils;
import java.util.Calendar;
import java.util.Locale;

/*
 * Copyright (C) 2015 Marco Hernaiz Cao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.marcohc.architecture.common.util;



/**
 * Calendar and date useful methods
 */
public class DateUtils {

    // ************************************************************************************************************************************************************************
    // * Calendar methods
    // ************************************************************************************************************************************************************************

    public static String formatCurrentMonth(Calendar calendar) {
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarCurrentMonthString() {
        Calendar calendar = Calendar.getInstance();
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarLastMonthString() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);
        return StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", calendar));
    }

    public static String getCalendarLastThreeMonthsString() {
        String text = "";
        Calendar initCalendar = Calendar.getInstance();
        Calendar endCalendar = getCalendarThreeMonthsAgo();
        endCalendar.add(Calendar.MONTH, 1);
        text = StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", endCalendar).substring(0, 3));
        text += " - " + StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", initCalendar).substring(0, 3));
        return text;
    }

    public static String getCalendarLastSixMonthsString() {
        String text = "";
        Calendar initCalendar = Calendar.getInstance();
        Calendar endCalendar = getCalendarSixMonthsAgo();
        endCalendar.add(Calendar.MONTH, 1);
        text = StringUtils.getFirstCapitalize(String.format(Locale.getDefault(), "%tB", endCalendar).substring(0, 3));