Java Code Examples for java.util.Locale#PRC

The following examples show how to use java.util.Locale#PRC . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateUtils.java    From a with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 将yyyy-MM-dd HH:mm:ss字符串转换成日期<br/>
 *
 * @param dateStr    时间字符串
 * @param dataFormat 当前时间字符串的格式。
 * @return Date 日期 ,转换异常时返回null。
 */
public static Date parseDate(String dateStr, String dataFormat) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.PRC);
        Date date = dateFormat.parse(dateStr);
        return new Date(date.getTime());
    } catch (ParseException e) {
        return null;
    }
}
 
Example 2
Source File: DateUtils.java    From FilePicker with MIT License 5 votes vote down vote up
/**
 * 将yyyy-MM-dd HH:mm:ss字符串转换成日期<br/>
 *
 * @param dateStr    时间字符串
 * @param dataFormat 当前时间字符串的格式。
 * @return Date 日期 ,转换异常时返回null。
 */
public static Date parseDate(String dateStr, String dataFormat) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.PRC);
        Date date = dateFormat.parse(dateStr);
        return new Date(date.getTime());
    } catch (ParseException e) {
        LogUtils.warn(e);
        return null;
    }
}
 
Example 3
Source File: DateUtils.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 将yyyy-MM-dd HH:mm:ss字符串转换成日期<br/>
 *
 * @param dateStr    时间字符串
 * @param dataFormat 当前时间字符串的格式。
 * @return Date 日期 ,转换异常时返回null。
 */
public static Date parseDate(String dateStr, String dataFormat) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.PRC);
        Date date = dateFormat.parse(dateStr);
        return new Date(date.getTime());
    } catch (ParseException e) {
        return null;
    }
}
 
Example 4
Source File: DateUtils.java    From AndroidDownload with Apache License 2.0 5 votes vote down vote up
/**
 * 将yyyy-MM-dd HH:mm:ss字符串转换成日期<br/>
 *
 * @param dateStr    时间字符串
 * @param dataFormat 当前时间字符串的格式。
 * @return Date 日期 ,转换异常时返回null。
 */
public static Date parseDate(String dateStr, String dataFormat) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.PRC);
        Date date = dateFormat.parse(dateStr);
        return new Date(date.getTime());
    } catch (ParseException e) {
        LogUtils.warn(e);
        return null;
    }
}
 
Example 5
Source File: ExampleUnitTest.java    From android with MIT License 5 votes vote down vote up
@Test
public void testStringLocale() throws Exception {
    Locale[] locales = new Locale[]{
            Locale.CANADA,
            Locale.CANADA_FRENCH,
            Locale.CHINESE,
            Locale.ENGLISH,
            Locale.FRANCE,
            Locale.GERMAN,
            Locale.GERMANY,
            Locale.ITALIAN,
            Locale.ITALY,
            Locale.JAPAN,
            Locale.JAPANESE,
            Locale.KOREA,
            Locale.KOREAN,
            Locale.PRC,
            Locale.ROOT,
            Locale.SIMPLIFIED_CHINESE,
            Locale.TAIWAN,
            Locale.TRADITIONAL_CHINESE,
            Locale.UK,
            Locale.US
    };

    String weightString = null;
    for (Locale locale : locales) {
        try {
            weightString = formatFloatWithOneDot(locale, 55.4f);
            float weight = Float.parseFloat(weightString);
        } catch (NumberFormatException e) {
            System.out.println(locale + ">>>>>" + weightString + ">>>>>>>>>> error");
            continue;
        }
        System.out.println(locale + ">>>>>" + weightString);
    }
}
 
Example 6
Source File: DateUtils.java    From AndroidPicker with MIT License 5 votes vote down vote up
/**
 * 将yyyy-MM-dd HH:mm:ss字符串转换成日期<br/>
 *
 * @param dateStr    时间字符串
 * @param dataFormat 当前时间字符串的格式。
 * @return Date 日期 ,转换异常时返回null。
 */
public static Date parseDate(String dateStr, String dataFormat) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.PRC);
        Date date = dateFormat.parse(dateStr);
        return new Date(date.getTime());
    } catch (ParseException e) {
        LogUtils.warn(e);
        return null;
    }
}
 
Example 7
Source File: DateUtils.java    From a with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 将指定的日期转换为一定格式的字符串
 */
public static String formatDate(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.PRC);
    return sdf.format(date);
}
 
Example 8
Source File: DateUtils.java    From FilePicker with MIT License 4 votes vote down vote up
/**
 * 将指定的日期转换为一定格式的字符串
 */
public static String formatDate(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.PRC);
    return sdf.format(date);
}
 
Example 9
Source File: DateUtils.java    From MyBookshelf with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 将指定的日期转换为一定格式的字符串
 */
public static String formatDate(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.PRC);
    return sdf.format(date);
}
 
Example 10
Source File: DateUtils.java    From AndroidDownload with Apache License 2.0 4 votes vote down vote up
/**
 * 将指定的日期转换为一定格式的字符串
 */
public static String formatDate(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.PRC);
    return sdf.format(date);
}
 
Example 11
Source File: DateUtils.java    From AndroidPicker with MIT License 4 votes vote down vote up
/**
 * 将指定的日期转换为一定格式的字符串
 */
public static String formatDate(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.PRC);
    return sdf.format(date);
}