Java Code Examples for java.util.Locale.CHINA

The following are Jave code examples for showing how to use CHINA of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: DateTest_tz.java   View Source Code Vote up 6 votes
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();
}
 
Example 2
Project: WebAndAppUITesting   File: TimeUtil.java   View Source Code Vote up 6 votes
/**
 * 根据设置格式类型,获取当前日期时间
 * 
 * @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());
}
 
Example 3
Project: androidtools   File: CustomDatePicker.java   View Source Code Vote up 6 votes
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();
    }
}
 
Example 4
Project: dswork   File: TimeUtil.java   View Source Code Vote up 6 votes
/**
 * 格式化时间
 * @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;
	}
}
 
Example 5
Project: CXJPadProject   File: NormalUtil.java   View Source Code Vote up 5 votes
/**
 * 把毫秒格式化成日期输出
 *
 * @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;
}
 
Example 6
Project: Watermark   File: MediaGridFragment.java   View Source Code Vote up 5 votes
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);
    }
 
Example 7
Project: VanGogh   File: VanConfig.java   View Source Code Vote up 5 votes
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");
}
 
Example 8
Project: CXJPadProject   File: NormalUtil.java   View Source Code Vote up 5 votes
/**
 * 把毫秒格式化成日期输出
 *
 * @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;
}
 
Example 9
Project: VanGogh   File: MainActivity.java   View Source Code Vote up 5 votes
/**
 * 跳转到裁剪页面
 *
 * @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);
}
 
Example 10
Project: azeroth   File: I18nUtils.java   View Source Code Vote up 5 votes
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;
}
 
Example 11
Project: GitHub   File: Bug_for_lenolix_8.java   View Source Code Vote up 4 votes
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.");
}
 
Example 12
Project: GitHub   File: DefaultJSONParserTest_date.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
Example 13
Project: GitHub   File: DateParserTest.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
Example 14
Project: YiZhi   File: DateUtils.java   View Source Code Vote up 4 votes
public static String date2str(Date date, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
    return sdf.format(date);
}
 
Example 15
Project: GitHub   File: Bug_for_issue_316.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
Example 16
Project: GitHub   File: DateParseTest5.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
Example 17
Project: ZhaZhaShop   File: TimeUtils.java   View Source Code Vote up 4 votes
public static String dateYMD(long time) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    return format.format(time);
}
 
Example 18
Project: GitHub   File: Bug_for_80108116.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}
 
Example 19
Project: GitHub   File: Bug_for_lenolix_7.java   View Source Code Vote up 4 votes
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");
}
 
Example 20
Project: GitHub   File: DateTest_ISO8601_TimeZone.java   View Source Code Vote up 4 votes
protected void setUp() throws Exception {
    JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
    JSON.defaultLocale = Locale.CHINA;
}