Example usage for java.util Locale CHINA

List of usage examples for java.util Locale CHINA

Introduction

In this page you can find the example usage for java.util Locale CHINA.

Prototype

Locale CHINA

To view the source code for java.util Locale CHINA.

Click Source Link

Document

Useful constant for country.

Usage

From source file:Main.java

public static File getNewFile(Context context, String folderName) {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA);

    String timeStamp = simpleDateFormat.format(new Date());

    String path;/* w ww . j  ava 2s.co  m*/
    if (isSDAvailable()) {
        path = getFolderName(folderName) + File.separator + timeStamp + ".jpg";
    } else {
        path = context.getFilesDir().getPath() + File.separator + timeStamp + ".jpg";
    }

    if (TextUtils.isEmpty(path)) {
        return null;
    }

    return new File(path);
}

From source file:Main.java

private static String byte2String(byte[] b) {
    StringBuilder hs = new StringBuilder();
    String stmp;/*from w w w .  jav a  2s .c  om*/
    for (int n = 0; b != null && n < b.length; n++) {
        stmp = Integer.toHexString(b[n] & 0XFF);
        if (stmp.length() == 1)
            hs.append('0');
        hs.append(stmp);
    }
    return hs.toString().toUpperCase(Locale.CHINA);
}

From source file:Main.java

public static String transformMillisToDate(long millis) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(millis);/*from   w  w  w  .j  a  va2s.c o  m*/
    // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm",
    // Locale.CHINA);
    SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm", Locale.CHINA);
    return format.format(calendar.getTime());
}

From source file:Main.java

public static String formatDateTime(Timestamp timestamp, String fmt) {
    SimpleDateFormat format = new SimpleDateFormat(fmt, Locale.CHINA);
    return format.format(timestamp);
}

From source file:Main.java

private static String formatCurrentTime(long currentTimeMillis) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.CHINA);
    Date currentDate = new Date(currentTimeMillis);
    return simpleDateFormat.format(currentDate);
}

From source file:Main.java

public static String convertUtc2Local(String utcTime) {
    String time = "";
    if (utcTime != null) {
        // 2014-10-24T02:58:05.932Z
        SimpleDateFormat utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.CHINA);
        utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date gpsUTCDate = null;//from   w  w  w .  j a  v  a2  s .c  o  m
        try {
            gpsUTCDate = utcFormatter.parse(utcTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat localFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
        localFormatter.setTimeZone(TimeZone.getDefault());
        assert gpsUTCDate != null;
        time = localFormatter.format(gpsUTCDate.getTime());
    }
    return time;
}

From source file:Main.java

public static Date getDate(String dateStr, String parsePattern) throws ParseException {
    Locale locale = Locale.CHINA;
    SimpleDateFormat dataformat = new SimpleDateFormat(parsePattern, locale);
    Date date = dataformat.parse(dateStr);
    return date;/*from   w ww.j  a v a2 s .com*/
}

From source file:Main.java

private static void saveWeatherInfo(Context context, String city, String cityid, String temp1, String temp2,
        String weather, String ptime) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d", Locale.CHINA);
    SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(context).edit();
    edit.putBoolean("city_selected", true);
    edit.putString("city", city);
    edit.putString("cityid", cityid);
    edit.putString("temp1", temp1);
    edit.putString("temp2", temp2);
    edit.putString("weather", weather);
    edit.putString("ptime", ptime);
    edit.putString("ctime", format.format(new Date()));
    edit.commit();/*from w  ww .j  av a  2s .  c o m*/
}

From source file:Main.java

public static String getParseDateToStr(Date date, String parsePattern) {
    Locale locale = Locale.CHINA;
    SimpleDateFormat dataformat = new SimpleDateFormat(parsePattern, locale);
    return dataformat.format(date);
}

From source file:Main.java

public static String getStringByOffset(String strDate, String format, int calendarField, int offset) {
    String mDateTime = null;/*from   ww  w .j  a va2 s . co  m*/
    try {
        Calendar c = new GregorianCalendar();
        SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format, Locale.CHINA);
        c.setTime(mSimpleDateFormat.parse(strDate));
        c.add(calendarField, offset);
        mDateTime = mSimpleDateFormat.format(c.getTime());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return mDateTime;
}