Last active
October 30, 2015 06:15
-
-
Save amake/eb5487bc2c87ee6eaed9 to your computer and use it in GitHub Desktop.
ISO 8601 Week Year Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jython | |
# Test standard Java classes | |
from java.text import * | |
from java.lang import * | |
fmty = SimpleDateFormat('yyyy-MM-dd') | |
date = fmty.parse('2015-12-27', ParsePosition(0)) | |
print fmty.format(date, StringBuffer(), FieldPosition(0)) # 2015-12-27 | |
fmtY = SimpleDateFormat('YYYY-MM-dd') | |
print fmtY.format(date, StringBuffer(), FieldPosition(0)) # 2016-12-27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
let fmty = NSDateFormatter() | |
fmty.dateFormat = "yyyy-MM-dd" | |
let date = fmty.dateFromString("2015-12-27") | |
fmty.stringFromDate(date!) // "2015-12-27" | |
let fmtY = NSDateFormatter() | |
fmtY.dateFormat = "YYYY-MM-dd" | |
fmtY.stringFromDate(date!) // "2016-12-27" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment