SimpleDateFormat星期几

时间:2015-11-11 20:52:13

标签: java android date simpledateformat

目前我这样做:

func beginSession(device: AVCaptureDevice) {

    do {
        let input = try? AVCaptureDeviceInput(device: captureDevice)

        if (captureSession.canAddInput(input)){

            captureSession.addInput(input)

            previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
            self.cameraView.layer.addSublayer(previewLayer!)

            previewLayer?.frame = self.view.layer.frame
            previewLayer?.videoGravity = AVLayerVideoGravityResizeAspect
            previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.Portrait
            captureSession.startRunning()

            stillImageOutput.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG]
            if captureSession.canAddOutput(stillImageOutput) {
                captureSession.addOutput(stillImageOutput)
            }
            if captureSession.canAddOutput(videoOutput) {
                captureSession.addOutput(videoOutput)
            }

            captureSession.addOutput(stillImageOutput)





        }

    }

}

但是DateFormat dateInstance = new SimpleDateFormat("EEE"); --> e.g.: Mo. DateFormat dateInstance2 = SimpleDateFormat.getDateInstance(); --> 09.11.2015 String s = dateInstance.format(date) + " " + dateInstance2.format(date); 标有我应该使用的消息SimpleDateFormat.get .... 但我需要这样的输出“Mon. 09.11.2015”。没有编译器的通知。请求帮助

2 个答案:

答案 0 :(得分:1)

你可能需要这个吗?

DateFormat dateInstance = new SimpleDateFormat("EEE yyyy.MM.dd", Locale.ENGLISH);
String s = dateInstance.format(date);

答案 1 :(得分:0)

@SuppressLint("SimpleDateFormat")添加到您的方法或类中。例如:

@SuppressLint("SimpleDateFormat")
public MonthAdapter(Context context, String monthFormat) {
    super(context, _months);

    _simpleDateFormat = new SimpleDateFormat(monthFormat);
}