是否可以将日期显示为2015年1月1日而不是20150101?

时间:2015-06-11 14:05:15

标签: android

基本上我只想知道是否可以通过相机意图将图像保存到Image_01Jan2015.jpg而不是Image_20150101来保存日期?

这是我的代码,但我想知道是否可以像Image_01Jan2015一样保存它?

Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File imagesFolder = new File(Environment.getExternalStorageDirectory(), "My Images");
    imagesFolder.mkdirs();
    image = new File(imagesFolder.getPath(), "Image_" + timeStamp + ".jpg");

    fileUri = Uri.fromFile(image);

由于

4 个答案:

答案 0 :(得分:2)

您需要将dateformat更改为

SimpleDateFormat("ddMMMyyyy_HHmmss")

timeStamp = new SimpleDateFormat("yyyyMMyyyy_HHmmss").format(new Date());

答案 1 :(得分:0)

是的,有可能。你必须改变你传递给SimpleDateFormat-Constructer的格式字符串,来自

NOT INSTANCE OF YourApp\Model\Citation

new SimpleDateFormat("yyyyMMdd_HHmmss")

答案 2 :(得分:0)

尝试替换:

timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());

with:

timeStamp = new SimpleDateFormat("ddMMMyyyy").format(new Date());   

您可以使用Android Developer API指南试用其他表单:http://developer.android.com/reference/java/text/SimpleDateFormat.html

答案 3 :(得分:0)

更改此行:

timeStamp = new SimpleDateFormat("yyyyMMyyyy_HHmmss").format(new Date());

timeStamp = new SimpleDateFormat("d MMM yyyy").format(new Date());

请参阅官方SimpleDateFormat