小编Ale*_*ser的帖子

客户端发送的请求在语法上是不正确的Java ZonedDateTime后端

我希望得到一些帮助调试此问题.如果我将以下JSON发送到我的后端,它可以正常工作:

{
    "approvalRequired": false,
    "location": {
        "locationName": "<+37.33233141,-122.03121860> +\/- 5.00m (speed 0.00 mps \/ course -1.00) @ 9\/16\/18, 9:24:59 PM Pacific Daylight Time",
        "longitude": -122.0312186,
        "latitude": 37.332331410000002
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我现在发送以下内容:

{
    "approvalRequired": false,
    "scheduledStartTime": "2016-01-01T10:24:00+01:00",
    "location": {
        "locationName": "<+37.33233141,-122.03121860> +\/- 5.00m (speed 0.00 mps \/ course -1.00) @ 9\/16\/18, 9:24:59 PM Pacific Daylight Time",
        "longitude": -122.0312186,
        "latitude": 37.332331410000002
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到了上述错误.在我的后端代码中,我有以下内容:

@DynamoDBTypeConverted(converter = ZonedDateTimeTypeConverter.class)
@DynamoDBAttribute(attributeName = "scheduledStartTime")
public ZonedDateTime scheduledStartTime;
Run Code Online (Sandbox Code Playgroud)

API方法签名如下所示:

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity create(@RequestBody Event event) {...} …
Run Code Online (Sandbox Code Playgroud)

java spring http-status-code-400 swift zoneddatetime

9
推荐指数
1
解决办法
255
查看次数

Flutter Web ShowMenu 不随屏幕大小调整而移动

棘手的问题,希望有人有好的想法。

showMenu(...)在 flutter 中调用我的文本按钮,效果很好。但是,有时在调整屏幕大小期间,菜单会卡在屏幕上的某个位置(远离其预期位置)。有时它会遵循其锚定位置。非常奇怪,我也注意到下拉菜单的这种行为。

这是我的示例代码。我想要么始终随屏幕移动菜单,或者在最坏的情况下,在屏幕调整大小事件上隐藏菜单。任何关于如何做的想法都会很棒!

class ZHomeMenuBar extends StatefulWidget {
  const ZHomeMenuBar({Key? key}) : super(key: key);

  @override
  State<ZHomeMenuBar> createState() => _ZHomeMenuBarState();
}

class _ZHomeMenuBarState extends State<ZHomeMenuBar> {
  final GlobalKey _mesKey = GlobalKey();
  final GlobalKey _accKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    final zuser = Provider.of<ZUser?>(context);
    return Container(
      height: 66,
      decoration: BoxDecoration(color: context.backgroundColor),
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
      child: Row(
        children: [
          Text(zuser == null ? "" : zuser.displayName ?? ""),
          const Spacer(),
          ZTextButton(text: "Portfolio", onPressed: () => …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web

8
推荐指数
1
解决办法
1265
查看次数

DateTimeFormatter接受多个日期并转换为一个日期(java.time库)

我正在尝试编写一个DateTimeFormatter允许我采用多种不同String格式的格式,然后将String格式转换为特定类型.由于项目的范围和已经存在的代码,我不能使用不同类型的格式化程序.

例如,我想接受MM/dd/yyyy以及yyyy-MM-dd'T'HH:mm:ss然后当我打印时我只想打印MM/dd/yyyy格式并在我打电话时将其格式化LocalDate.format(formatter);

有人可以建议如何用这个做到这一点 java.time.format.*;

以下是我可以做到的方式org.joda:

// MM/dd/yyyy format
DateTimeFormatter monthDayYear = DateTimeFormat.forPattern("MM/dd/yyyy");
// array of parsers, with all possible input patterns
DateTimeParser[] parsers = {
        // parser for MM/dd/yyyy format
        monthDayYear.getParser(),
        // parser for yyyy-MM-dd'T'HH:mm:ss format
        DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").getParser()
};
DateTimeFormatter parser = new DateTimeFormatterBuilder()
    // use the monthDayYear formatter for output (monthDayYear.getPrinter())
    // and parsers array for input (parsers)
    .append(monthDayYear.getPrinter(), parsers)
    // create formatter (using UTC …
Run Code Online (Sandbox Code Playgroud)

java datetime datetime-format datetime-parsing java-time

7
推荐指数
1
解决办法
4559
查看次数

没有索引路径表格单元格在Swift中重用

我注意到在Obj-C中有很多问题,但我几乎不记得Obj-C,每个答案都是针对这个问题的.在这里我得到这个错误:"有时当应用程序刷新时,表单元格没有重复使用的索引路径".我注意到,当我不刷新但是我离开并重新打开表视图时,格式化已经毁了.

这是我在几个地方使用的"刷新"方法:

   @IBAction func loadData(){
        timeLineData.removeAllObjects()
        //pulls the data from the server
        var findTimeLineData: PFQuery = PFQuery(className: "Sweets")
        findTimeLineData.findObjectsInBackgroundWithBlock{
            (objects:[AnyObject]!, error: NSError!) -> Void in
            if !error{
                for object:PFObject! in objects{
                    self.timeLineData.addObject(object)
                }
                let tempArray: NSArray = self.timeLineData.reverseObjectEnumerator().allObjects
                self.timeLineData = tempArray as NSMutableArray

                //reloads the data in the table view
                self.tableView.reloadData()
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

而tableview方法:

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
    let cell: SweetTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as SweetTableViewCell

    let sweet: PFObject = self.timeLineData.objectAtIndex(indexPath.row) as …
Run Code Online (Sandbox Code Playgroud)

uitableview tableview ios swift

6
推荐指数
1
解决办法
698
查看次数

类型“ X”不符合协议“可编码”

我希望在这里能理解此错误,并且可能对可编码和可解码的内容有更广泛的了解。我班的一部分看起来如下:

  public var eventId: String?
  public var eventName: String?
  public var eventDescription: String?
  public var location: CLLocation?

  /// These properties will be encoded/decoded from JSON
  private enum CodingKeys: String, CodingKey {
    case eventId
    case eventName
    case eventDescription
    case location
  }

  public required convenience init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)

    let eventId = try container.decode(String?.self, forKey: .eventId)
    let eventName = try container.decode(String?.self, forKey: .eventName)
    let location = try container.decode(CLLocation?.self, forKey: .location)
    self.init(eventId: eventId, eventName: eventName, location:location) …
Run Code Online (Sandbox Code Playgroud)

xcode ios swift codable

5
推荐指数
1
解决办法
7378
查看次数

理解 Firestore 安全规则 - 只允许更新某些字段

我正在尝试使用 Firestore 安全规则来编辑一些数据,如下所示,在 Flutter 中有一个事务

  Future sendRequest(uidSend, uidRec, pid, title) async {
    final crSend = ChatRequest(uid: uidRec, pid: pid, title: title);
    var _lsSend = List();
    _lsSend.add(crSend.toJson());

    final crRec = ChatRequest(uid: uidSend, pid: pid, title: title);
    var _lsRec = List();
    _lsRec.add(crRec.toJson());

    final uMSendDocref = userMetadataCollection.document(uidSend);
    final uMRecDocref = userMetadataCollection.document(uidRec);

    Firestore.instance.runTransaction((transaction) async {
      await transaction.update(uMSendDocref, <String, dynamic>{
        "sentRequests": FieldValue.arrayUnion(
          _lsSend,
        ),
      });
      await transaction.update(uMRecDocref, <String, dynamic>{
        "receivedRequests": FieldValue.arrayUnion(
          _lsRec,
        ),
      });
    });
  }
Run Code Online (Sandbox Code Playgroud)

请注意,用户 1 正在尝试更新他/她自己的数据以及用户 2 的数据。但是,我只希望 user1 能够更新 …

firebase firebase-security flutter google-cloud-firestore

5
推荐指数
1
解决办法
159
查看次数

先遍历二维数组行,然后先遍历列

我正在寻找一种方法来遍历 2d n by m int 数组 (int[col][row]),在 Java 中首先逐行(简单部分)然后逐列遍历。这是逐行执行的代码,有没有办法逐行执行col?

for(int i = 0; i < display.length; i++){
            for (int j = 0; j < display[i].length; j++){
                if (display[i][j] == 1)
                    display[i][j] = w++;
                else w = 0;
            }
        }
Run Code Online (Sandbox Code Playgroud)

java arrays 2d

4
推荐指数
1
解决办法
3万
查看次数

在Java中将文件移动到不同的s3Location

我的用例如下.我想使用Java S3 SDK将文件从某个s3Location移动到不同的s3Location.例如,如果文件在bucket/current,我想将其移动到bucket/old.

我目前可以下载一个文件作为S3Object,将该对象转换为文件(java.io,因为S3 Java客户端因为我不明白的原因不允许你上传一个S3Object,你下载的对象非常相同!)并上传该文件.我很好奇是否有更好的方法.

谢谢!

java amazon-s3

4
推荐指数
1
解决办法
4906
查看次数

强制 Moment.js format() 忽略夏令时 JS

我目前处于-07:00UTC 的太平洋标准时间 (PST)。

如果我这样做:moment().format('Z')我正确地得到了-07:00. 有没有办法(简单地)强制 moment.format() 忽略夏令时(在我的情况下给我-08:00)?

javascript dst momentjs

4
推荐指数
1
解决办法
1万
查看次数

尝试使用Apache Poi制作简单的PDF文档

我看到互联网上满是抱怨apache pdf产品的人,但是我在这里找不到我的特殊用例。我正在尝试使用apache poi做一个简单的Hello World。现在,我的代码如下:

public ByteArrayOutputStream export() throws IOException {
    //Blank Document
    XWPFDocument document = new XWPFDocument();

    //Write the Document in file system
    ByteArrayOutputStream out = new ByteArrayOutputStream();;

    //create table
    XWPFTable table = document.createTable();
    XWPFStyles styles = document.createStyles();
    styles.setSpellingLanguage("English");
    //create first row
    XWPFTableRow tableRowOne = table.getRow(0);
    tableRowOne.getCell(0).setText("col one, row one");
    tableRowOne.addNewTableCell().setText("col two, row one");
    tableRowOne.addNewTableCell().setText("col three, row one");

    //create second row
    XWPFTableRow tableRowTwo = table.createRow();
    tableRowTwo.getCell(0).setText("col one, row two");
    tableRowTwo.getCell(1).setText("col two, row two");
    tableRowTwo.getCell(2).setText("col three, row two");

    //create third row …
Run Code Online (Sandbox Code Playgroud)

java apache apache-poi

4
推荐指数
1
解决办法
8166
查看次数

如何将现有对象保存到 Core Data

我一直在做一个项目并且有一个我正在使用的现有对象。我试图找到一种简单的方法来保存、检索和删除 Core Data 中这些对象的列表。

这是我的对象

import Foundation

class Book : Codable {

    var coverIndex:Int?
    var authorName:[String]?
    var title:String?
    var editionCount:Int?
    var firstPublishYear:Int?
    var key: String?
    var publishPlace:[String]?
    var publisher:[String]?

    public enum BookResponseCodingKeys: String, CodingKey {
        case coverIndex = "cover_i"
        case authorName = "author_name"
        case editionCount = "edition_count"
        case firstPublishYear = "first_publish_year"
        case key = "key"
        case title = "title"
        case publishPlace = "publish_place"
        case publisher = "publisher"
    }

    public required init(from decoder: Decoder) throws {

        let container = try decoder.container(keyedBy: …
Run Code Online (Sandbox Code Playgroud)

core-data ios swift

3
推荐指数
1
解决办法
4522
查看次数

locationManager.location is always nil

I have essentially lifted this code from the internet:

//variables
//location manager
var locationManager:CLLocationManager!
var currentLocation:CLLocation?

//outlets
@IBOutlet weak var whatTextField: UITextField!
@IBOutlet weak var whereTextField: UITextField!
@IBOutlet weak var whenTextField: UITextField!

@IBAction func onCreateEventClick(_ sender: Any) {

    let event = CAEvent(eventId: "123777abc", eventName: whatTextField.text, location: currentLocation)
    event.save { (error) in
        //handle event error
        print(error)
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    if( CLLocationManager.authorizationStatus() == .authorizedWhenInUse ||
        CLLocationManager.authorizationStatus() ==  .authorizedAlways){
        determineCurrentLocation()
    } …
Run Code Online (Sandbox Code Playgroud)

cllocation ios swift

0
推荐指数
1
解决办法
2210
查看次数