有没有办法在 Java/Kotlin 中以正确的语言环境顺序格式化日期和月份(以紧凑形式)而不是年份?所以对于英语应该是“Sep 20”,但对于瑞典语应该是“20 sep.”。
为了比较,在 Cocoa 平台上,我可以执行以下操作(在 Swift 中):
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "sv_SE")
formatter.setLocalizedDateFormatFromTemplate("MMM d")
print(formatter.string(from: Date()))
Run Code Online (Sandbox Code Playgroud)
这将正确地扭转局面。Java SDK 是否有相同的功能?我一直在尝试各种形式DateTimeFormatter
的SimpleTimeFormat
API和旧API,但没有成功。
注意:与此问题不同,我不想要包含年份的完整媒体格式。我也不想要DateTimeFormatter.ofPattern("MMM d")
,因为这在瑞典语中给出了不正确的结果,或者DateTimeFormatter.ofPattern("d MMM")
,因为在英语中给出了不正确的结果。
我尝试在我的网站上使用Google登录,但是,它一直给我400错误.
我引用了这篇文章:https://developers.google.com/identity/sign-in/web/sign-in,我的代码非常简单:
<html>
<head>
<title>Test Google Login</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="<CHANGE IT>">
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId());
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
}
</script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我点击登录按钮时,它弹出一个窗口,登录后,它给了我400错误,如下所示:
400. That’s an error.
The requested URL was not found on this server. That’s all we know.
Run Code Online (Sandbox Code Playgroud)
我想这是重定向问题,但我不知道如何配置它.所以我查了url它还给了我:
https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0
Run Code Online (Sandbox Code Playgroud)
为什么redirect_uri"storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?
我正在尝试构建一个我有一段时间没有重新访问过的项目。我以 GNOME 应用程序的典型方式使用 GNU 自动工具。现在,当运行autogen.sh
(反过来使用gnome-autogen.sh
)时,我收到以下错误:
automake: warnings are treated as errors
configure.ac:47: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
configure.ac:47: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
configure.ac:47: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
autoreconf: automake failed with exit status: 1
[simon:~/git/toddlerfun] master(+2/-2) 1 ±
Run Code Online (Sandbox Code Playgroud)
问题似乎源于 gettext,运行此错误报告中的命令给出了相同的结果:
$ grep -ri AM_PROG_MKDIR_P m4
m4/intl.m4: AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
m4/po.m4: AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
$ head -n1 m4/po.m4 …
Run Code Online (Sandbox Code Playgroud) automake ×1
c ×1
glib ×1
gnome ×1
google-api ×1
google-oauth ×1
java ×1
localization ×1
meteor ×1
unicode ×1
utf-8 ×1