本文整理匯總了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());
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}
示例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.");
}
示例12: setUp
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
示例13: date2str
public static String date2str(Date date, String format) {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
return sdf.format(date);
}
示例14: dateYMD
public static String dateYMD(long time) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
return format.format(time);
}
示例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");
}