當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.CHINA屬性代碼示例

本文整理匯總了Java中java.util.Locale.CHINA屬性的典型用法代碼示例。如果您正苦於以下問題:Java Locale.CHINA屬性的具體用法?Java Locale.CHINA怎麽用?Java Locale.CHINA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.Locale的用法示例。


在下文中一共展示了Locale.CHINA屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCurrentDateTime

/**
 * 根據設置格式類型,獲取當前日期時間
 * 
 * @param type
 *          返回日期時間形式<br>
 *          0, 20130123150123<br>
 *          1, 2013-01-23T15:01:23.357<br>
 *          2, 20130123<br>
 *          3, 150123<br>
 *          4, 15:01:23.456<br>
 *          默認, 20130123150123<br>
 * 
 * @return String 日期時間字符串
 */
public static String getCurrentDateTime(int type) {
	String pattern = "yyyyMMddHHmmss";

	switch (type) {
	case 0: // 默認值
		break;
	case 1:
		pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS";
		break;
	case 2:
		pattern = "yyyyMMdd";
		break;
	case 3:
		pattern = "HHmmss";
		break;
	case 4:
		pattern = "HH:mm:ss.SSS";
		break;
	default: // 默認值
		break;
	}
	SimpleDateFormat df = new SimpleDateFormat(pattern, Locale.CHINA); // 設置日期格式
	return df.format(new Date());
}
 
開發者ID:quanqinle,項目名稱:WebAndAppUITesting,代碼行數:38,代碼來源:TimeUtil.java

示例2: test_codec

public void test_codec() throws Exception {
    JSONReader reader = new JSONReader(new StringReader("{\"value\":\"2016-04-29\"}"));
    reader.setLocale(Locale.CHINA);
    reader.setTimzeZone(TimeZone.getTimeZone("Asia/Shanghai"));
    
    Model model = reader.readObject(Model.class);
    Assert.assertNotNull(model.value);
    
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
    Date date = format.parse("2016-04-29");
    Assert.assertEquals(date.getTime(), model.value.getTime());
    
    Assert.assertEquals(TimeZone.getTimeZone("Asia/Shanghai"), reader.getTimzeZone());
    Assert.assertEquals(Locale.CHINA, reader.getLocal());
    
    reader.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:DateTest_tz.java

示例3: CustomDatePicker

public CustomDatePicker(Context context, ResultHandler resultHandler, String startDate, String endDate) {
    if (isValidDate(startDate, "yyyy-MM-dd HH:mm") && isValidDate(endDate, "yyyy-MM-dd HH:mm")) {
        canAccess = true;
        this.context = context;
        this.handler = resultHandler;
        selectedCalender = Calendar.getInstance();
        startCalendar = Calendar.getInstance();
        endCalendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
        try {
            startCalendar.setTime(sdf.parse(startDate));
            endCalendar.setTime(sdf.parse(endDate));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        initDialog();
        initView();
    }
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:19,代碼來源:CustomDatePicker.java

示例4: convertString

/**
 * 格式化時間
 * @param value 需要格式化的時間字符串
 * @param format 對應時間字符串的格式化參數,如:yyyy-MM-dd HH:mm:ss
 * @return Date
 */
public static Date convertString(String value, String format)
{
	SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
	if(value == null)
	{
		return null;
	}
	try
	{
		return sdf.parse(value);
	}
	catch(Exception e)
	{
		return null;
	}
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:22,代碼來源:TimeUtil.java

示例5: msToDate

/**
 * 把毫秒格式化成日期輸出
 *
 * @param ms
 * @throws Exception
 */
public static String msToDate(long ms) {
    long l = ms;
    Date date = new Date(l);
    SimpleDateFormat f = new SimpleDateFormat("MM月dd日 HH:mm", Locale.CHINA);
    String time = f.format(date);
    return time;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:13,代碼來源:NormalUtil.java

示例6: openCamera

public void openCamera(Context context) {


        boolean image = mConfiguration.isImage();

        Intent captureIntent = image ? new Intent(MediaStore.ACTION_IMAGE_CAPTURE) : new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        if (captureIntent.resolveActivity(context.getPackageManager()) == null) {
            Toast.makeText(getContext(), R.string.gallery_device_camera_unable, Toast.LENGTH_SHORT).show();
            return;
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
        String filename = String.format(image ? IMAGE_STORE_FILE_NAME : VIDEO_STORE_FILE_NAME, dateFormat.format(new Date()));
        Logger.i("openCamera:" + mImageStoreDir.getAbsolutePath());
        File fileImagePath = new File(mImageStoreDir, filename);
        mImagePath = fileImagePath.getAbsolutePath();

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(fileImagePath));
        } else {
            ContentValues contentValues = new ContentValues(1);
            contentValues.put(MediaStore.Images.Media.DATA, mImagePath);
            Uri uri = getContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
            captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        }
        // video : 1: 高質量  0 低質量
//        captureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(captureIntent, TAKE_IMAGE_REQUEST_CODE);
    }
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:29,代碼來源:MediaGridFragment.java

示例7: createImageFile

private File createImageFile() throws IOException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA);
    String imageFileName = "IMG_" + dateFormat.format(new Date());

    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    return new File(storageDir + File.separator + imageFileName + ".jpeg");
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:7,代碼來源:VanConfig.java

示例8: msToMinute

/**
 * 把毫秒格式化成日期輸出
 *
 * @param ms
 * @throws Exception
 */
public static int msToMinute(long ms) {
    long l = ms;
    Date date = new Date(l);
    SimpleDateFormat f = new SimpleDateFormat("mm", Locale.CHINA);
    String time = f.format(date);
    int h = 0;
    try {
        h = Integer.parseInt(time);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return h;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:19,代碼來源:NormalUtil.java

示例9: startCropActivity

/**
 * 跳轉到裁剪頁麵
 *
 * @param source 需要裁剪的圖片
 */
private void startCropActivity(Uri source) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA);
    String imageFileName = "IMG_" + dateFormat.format(new Date());

    Uri uri = Uri.fromFile(new File(getCacheDir(), imageFileName.concat(".jpeg")));
    UCrop.of(source, uri)
            .withAspectRatio(1, 1)
            .withMaxResultSize(1024, 1024)
            .withTargetActivity(VanCropActivity.class)
            .start(this);
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:16,代碼來源:MainActivity.java

示例10: getLocale

private static Locale getLocale(RequestHeader header) {
    Locale locale = Locale.CHINA;
    //		try {
    //			locale = StringUtils.isBlank(header.getLanguage()) ? Locale.CHINA : new Locale(header.getLanguage(),header.getArea());
    //		} catch (Exception e) {
    //			locale = Locale.CHINA;
    //		}
    return locale;
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:9,代碼來源:I18nUtils.java

示例11: setUp

protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;

    com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_8.");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Bug_for_lenolix_8.java

示例12: setUp

protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:DefaultJSONParserTest_date.java

示例13: date2str

public static String date2str(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
    return sdf.format(date);
}
 
開發者ID:Horrarndoo,項目名稱:YiZhi,代碼行數:4,代碼來源:DateUtils.java

示例14: dateYMD

public static String dateYMD(long time) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    return format.format(time);
}
 
開發者ID:coderwjq,項目名稱:ZhaZhaShop,代碼行數:4,代碼來源:TimeUtils.java

示例15: setUp

protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;

    ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_7");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Bug_for_lenolix_7.java


注:本文中的java.util.Locale.CHINA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。