def test_to_python_date_format_with_complex_date_format2(self): # Given java_date_format = "yy-MM-dd hh:mm:ss.SSS" # When actual_python_date_format = date.to_python_date_format( java_date_format) # Then assert "%Y-%m-%d %H:%M:%S.%f" == actual_python_date_format
def test_to_python_date_format_with_complex_date_format_3(self): # Given java_date_format = "dd/MM/yy hh:mm:ss.SSS" # When actual_python_date_format = date.to_python_date_format( java_date_format) # Then assert "%d/%m/%Y %H:%M:%S.%f" == actual_python_date_format
def test_to_python_date_format(self): # Given java_date_format = "yyyy-MM" # When actual_python_date_format = date.to_python_date_format( java_date_format) # Then assert "%Y-%m" == actual_python_date_format
def from_json(cls, data: dict, date_format: str): date = datetime.strptime(data["date"], to_python_date_format(date_format)) return cls(date, float(data["value"]))
def to_json(self, date_format: str) -> dict: return dict(date=self.date.strftime( to_python_date_format(date_format)), value=float(self.value))